Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
PersonalizeCloud Portal
Sitecore Personalize
        • プログラム可能な決定を意思決定キャンバスに追加する
        • 決定テンプレートを決定キャンバスに追加する
        • プログラム可能な決定の例
            • サポートされているJavaScript関数
            • サポートされていないJavaScript関数と代替手段
        • プログラム可能な決定でカスタムフィールドを使用する
        • プログラム可能な決定に日付を含める
        • プログラム可能な決定のコピー
        • プログラマブルな決定にprintステートメントを含める
        • プログラム可能な決定のトラブルシューティング
    • Sitecore Personalizeでのデータ・システムの管理
  • パーソナライゼーションでのクライアントサイドJavaScriptの使用
  • 用語集
  1. サポートされているエンティティとサポートされていないJavaScriptエンティティ
  1. Sitecore Personalize
  2. Sitecore Personalizeでの意思決定の概要

サポートされていないJavaScript関数と代替手段

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

このトピックでは、Sitecore PersonalizeでサポートされていないJavaScript関数と、代わりに使用できる代替関数について説明します。

次のJavaScriptエンティティはSitecore Personalizeではサポートされておらず、代替の例は提供されていません。

  • async関数

  • generator関数

  • map primitive関数

  • promiseオブジェクト

  • primitiveデータ型の設定

  • support一意の識別子としての記号

  • weakmapデータ構造

  • weaksetデータ構造

配列.エントリ

Sitecore PersonalizeはArray.entries機能をサポートしていません。次のJavaScriptを使用して、配列内のキーと値のペアを反復処理できる新しい配列イテレータ オブジェクトを返します。

var [a, ...b] = [1, 2, 3];
print(a); // 1
print(b); // [2, 3]

配列.find

Sitecore PersonalizeはArray.find機能をサポートしていません。別の方法として、次のJavaScriptを使用して、配列に存在する各要素を確認できます。コードでtrue値を持つ配列要素が見つかった場合は、その配列要素の値が返されます。

// Polyfill array.find
if (!Array.prototype.find) {
  Array.prototype.find = function(predicate) {
    if (this === null) {
      throw new TypeError('Array.prototype.find called on null or undefined');
    }
    if (typeof predicate !== 'function') {
      throw new TypeError('predicate must be a function');
    }
    var list = Object(this);
    var length = list.length >>> 0;
    var thisArg = arguments[1];
    var value;

    for (var i = 0; i < length; i++) {
      value = list[i];
      if (predicate.call(thisArg, value, i, list)) {
        return value;
      }
    }
    return undefined;
  };
}

配列.findIndex

Sitecore PersonalizeはArray.findIndex機能をサポートしていません。別の方法として、次のJavaScriptを使用して、true値を返す配列要素を確認できます。コードでtrue値を持つ配列要素が見つかった場合は、その配列要素のインデックスが返されます。残りの値はチェックされません。

// Polyfill array.findIndex
if (!Array.prototype.findIndex) {
        Array.prototype.findIndex = function(predicate) {
            if (this === null) {
                throw new TypeError('Array.prototype.findIndex called on null or undefined');
            }

            if (typeof predicate !== 'function') {
                throw new TypeError('predicate must be a function');
            }

            var list = Object(this);
            var length = list.length >>> 0;
            var thisArg = arguments[1];
            var value;

            for (var i = 0; i < length; i++) {
                value = list[i];
                if (predicate.call(thisArg, value, i, list)) {
                    return i;
                }
            }

            return -1;
        };
    }

配列.flat

次のJavaScriptを使用して、多次元配列を取得し、それを1次元配列に変換します。 reduceやspreadは、特定のシナリオで使用することも、コード サンプルに示すように分解構文で使用することもできます。Sitecore PersonalizeはArray.flat機能をサポートしていません。

// Possible to use reduce or spread for some cases
const array = [1, 2, [3, 4]];

array.reduce((acc, val) => acc.concat(val), []);
// [1, 2, 3, 4]

// or with decomposition syntax
const flattened = array => [].concat(...array);

// Polyfill for more complex/nested
if (!Array.prototype.flat) {
    Object.defineProperty(Array.prototype, 'flat', {
        configurable: true,
        value: function flat () {
            var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]);

            return depth ? Array.prototype.reduce.call(this, function (acc, cur) {
                if (Array.isArray(cur)) {
                    acc.push.apply(acc, flat.call(cur, depth - 1));
                } else {
                    acc.push(cur);
                }

                return acc;
            }, []) : Array.prototype.slice.call(this);
        },
        writable: true
    });
}

配列.flatMap

次のJavaScriptを使用して、入力配列要素を新しい配列にフラット化します。 reduceは、コード サンプルに示すように、特定のシナリオで使用できます。Sitecore PersonalizeはArray.flatMap機能をサポートしていません。

// Use reduce for some cases
var array = [1, 2, 3, 4];
array.reduce((acc, x) => acc.concat([x, x * 2]), []);
// [1, 2, 2, 4, 3, 6, 4, 8]

// Polyfill more complex cases
if (!Array.prototype.flatMap) {
    Object.defineProperty(Array.prototype, 'flatMap', {
        configurable: true,
        value: function flatMap (callback) {
            return Array.prototype.map.apply(this, arguments).flat();
        },
        writable: true
    });
}

Array.インクルード

次のJavaScriptを使用して、配列に指定された要素が含まれているかどうかを判断します。このコードは、配列に要素が含まれている場合はtrueを返し、含まれていない場合はfalseを返します。Sitecore PersonalizeはArray.includes関数をサポートしていません。

// Use indexOf with +1 to allow easy boolean check
const array1 = [""a"", ""b"", ""c""];
if(array1.indexOf(""a"")+1) {
 // do something
}

配列.keys

次のJavaScriptを使用して、配列のキーまたはキーのサブセットを返します。Sitecore PersonalizeはArray_keys機能をサポートしていません。

// Polyfill
if (![].keys) {
   Array.prototype.keys = function() {
       var k = 0, o = this;
       return {
          next: function(){
           return k < o.length ?
               {value: k++, done: false} :
               {done: true};
          }
       };
   };
}

配列.of

次のJavaScriptを使用して、配列のsliceメソッドを使用し、callを使用してオブジェクトに適用します。Sitecore PersonalizeはArray.of機能をサポートしていません。

// Polyfill
if (!Array.of) {
  Array.of = function() {
    return Array.prototype.slice.call(arguments);
    // Or 
    let vals = [];
    for(let prop in arguments){
        vals.push(arguments[prop]);
    }
    return vals;
  }
}

配列.値

次のJavaScriptを使用して、配列のすべての要素を返します。Sitecore PersonalizeはArray.values機能をサポートしていません。

// Polyfill
if (![].values) {
   Array.prototype.values = function() {
       var k, a = [], nextIndex = 0, ary = this;
       k = ary.length;
       while (k > 0) a[--k] = ary[k];
       a.next = function(){
           return nextIndex < ary.length ?
               {value: ary[nextIndex++], done: false} :
               {done: true};
       };
   return a;
   };
}

対して。。。の

次のJavaScriptを使用して、反復可能なオブジェクトを反復処理します。Sitecore Personalizeはfor...ofステートメントをサポートしていません。

const array1 = ['a', 'b', 'c'];
array1.forEach(value => {
  print(value)
});

オブジェクト.assign

次のJavaScriptを使用して、1つ以上のソース オブジェクトからターゲット オブジェクトに値をコピーします。Sitecore PersonalizeはObject.assign機能をサポートしていません。

// Polyfill
if (typeof Object.assign !== 'function') {
  // Must be writable: true, enumerable: false, configurable: true
  Object.defineProperty(Object, ""assign"", {
    value: function assign(target, varArgs) { // .length of function is 2
      'use strict';
      if (target === null || target === undefined) {
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = Object(target);

      for (var index = 1; index < arguments.length; index++) {
        var nextSource = arguments[index];

        if (nextSource !== null && nextSource !== undefined) { 
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    },
    writable: true,
    configurable: true
  });
}

オブジェクト.エントリ

次のJavaScriptを使用して、オブジェクトの定義方法に関係なく、指定された順序で、指定されたオブジェクト自体の列挙可能な文字列キー付きプロパティkey, valueペアの配列を返します。Sitecore PersonalizeはObject.entries機能をサポートしていません。

// Polyfill
if (typeof Object.assign !== 'function') {
  // Must be writable: true, enumerable: false, configurable: true
  Object.defineProperty(Object, ""assign"", {
    value: function assign(target, varArgs) { // .length of function is 2
      'use strict';
      if (target === null || target === undefined) {
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = Object(target);

      for (var index = 1; index < arguments.length; index++) {
        var nextSource = arguments[index];

        if (nextSource !== null && nextSource !== undefined) { 
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    },
    writable: true,
    configurable: true
  });
}

Object.js

次のJavaScriptを使用して、2つの値が同じかどうかを判断します。Sitecore PersonalizeはObject.js機能をサポートしていません。

// Polyfill
if (!Object.is) {
  Object.is = function(x, y) {
    if (x === y) { // Steps 1-5, 7-10
      return x !== 0 || 1 / x === 1 / y;
    } else {
      return x !== x && y !== y;
    }
  };
}

オブジェクト値

次のJavaScriptを使用して、指定されたオブジェクトの列挙可能なプロパティ値の配列を返します。Sitecore PersonalizeはObject.values機能をサポートしていません。

// Polyfill
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
const concat = Function.bind.call(Function.call, Array.prototype.concat);
const keys = Reflect.ownKeys;

if (!Object.values) {
    Object.values = function values(O) {
        return reduce(keys(O), (v, k) => concat(v, typeof k === 'string' && isEnumerable(O, k) ? [O[k]] : []), []);
    };
}
この記事を改善するための提案がある場合は、 お知らせください!

Documentation Assistant

This assistant uses AI to generate responses based on Sitecore documentation. While it has access to official sources, answers may be incomplete or inaccurate and should not be considered official advice or support.
Powered by
k
kapa.ai
Protected by reCAPTCHA

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use