Unsupported JavaScript functions and alternatives
This topic describes the JavaScript functions that are not supported in Sitecore Personalize and the alternative functions you can use instead.
The following JavaScript entities are not supported in Sitecore Personalize and we do not provide alternative examples:
-
asyncfunctions -
generatorfunctions -
map primitivefunctions -
promiseobjects -
set
primitivedata types -
supportsymbols as unique identifiers -
weakmapdata structure -
weaksetdata structure
Array.entries
Array.entries
Sitecore Personalize does not support the Array.entries function. Use the following JavaScript to return a new array iterator object that enables you to iterate through the key/value pairs in the array.
Array.find
Array.find
Sitecore Personalize does not support the Array.find function. As an alternative, you can use the following JavaScript to check for each element present in the array. If the code finds an array element with a true value, it returns the value of that array element.
Array.findIndex
Array.findIndex
Sitecore Personalize does not support the Array.findIndex function. As an alternative, you can use the following JavaScript to check for an array element that returns a true value. If the code finds an array element with a true value, it returns the index of that array element. It does not check the remaining values.
Array.flat
Array.flat
Use the following JavaScript to take a multidimensional array and turn it into a single dimensional array. You can use reduce or spread in certain scenarios or a decomposition syntax, as shown in the code sample. Sitecore Personalize does not support the Array.flat function.
Array.flatMap
Array.flatMap
Use the following JavaScript to flatten the input array element into a new array. You can use reduce in certain scenarios, as shown in the code sample. Sitecore Personalize does not support the Array.flatMap function.
Array.includes
Array.includes
Use the following JavaScript to determine whether an array contains a specified element. The code returns true if the array contains the element, and false if not. Sitecore Personalize does not support the Array.includes function.
Array.keys
Array.keys
Use the following JavaScript to return the keys or a subset of the keys of an array. Sitecore Personalize does not support the Array_keys function.
Array.of
Array.of
Use the following JavaScript to use the slice method of an array and apply it toward an object using call. Sitecore Personalize does not support the Array.of function.
Array.values
Array.values
Use the following JavaScript to return all the elements of the array. Sitecore Personalize does not support the Array.values function.
For...of
For...of
Use the following JavaScript to iterate over iterable objects. Sitecore Personalize does not support the for...of statement.
Object.assign
Object.assign
Use the following JavaScript to copy the values from one or more source objects to a target object. Sitecore Personalize does not support the Object.assign function.
Object.entries
Object.entries
Use the following JavaScript to return an array of a given object's own enumerable string-keyed property [key, value] pairs, in the same order as provided, regardless of how an object is defined. Sitecore Personalize does not support the Object.entries function.
Object.js
Object.js
Use the following JavaScript to determine whether two values are the same. Sitecore Personalize does not support the Object.js function.
Object.values
Object.values
Use the following JavaScript to return the array of the given object's enumerable property values. Sitecore Personalize does not support the Object.values function.