Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
CDPCloud Portal
Sitecore CDP
  • データ ブラウザー機能を使用する
        • カスタム条件を別のテナントにコピーする
        • 条件の管理
            • サポートされているJavaScript関数
            • サポートされていないJavaScript関数と代替手段
    • テナント間でのエンティティのコピー
  1. サポートされているエンティティとサポートされていないJavaScriptエンティティ
  1. Sitecore CDP
  2. デベロッパーセンター
  3. 条件
  4. サポートされているエンティティとサポートされていないJavaScriptエンティティ
  5. サポートされていない JavaScript 関数と代替手段

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

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

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

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

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

  • async関数

  • generator関数

  • map primitive関数

  • promiseオブジェクト

  • primitiveデータ型の設定

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

  • weakmapデータ構造

  • weaksetデータ構造

  • オプションのチェーン演算子 (?.)

  • nullish合体演算子 (??)

配列.エントリ

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

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

配列.find

Sitecore CDPArray.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 CDPArray.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 CDPでは、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 CDPでは、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 CDPは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 CDPは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 CDPは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 CDPは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 CDPはfor...ofステートメントをサポートしていません。

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

オブジェクト.assign

次のJavaScriptを使用して、1つ以上のソース オブジェクトからターゲット オブジェクトに値をコピーします。 Sitecore CDPは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 CDPは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 CDPは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 CDPは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