Object is available in SSJS. Only hasOwnProperty is officially documented in the SFMC SSJS engine. ES6 static methods (Object.keys(), Object.assign(), etc.) are not available.


hasOwnProperty

Returns true if the object has the specified property as its own (not inherited through the prototype chain). Use this method inside for...in loops to skip inherited prototype members.

Object.prototype.hasOwnProperty(v)

Parameters

Name Type Description
v string Property name to check

Return Value

booleantrue if the property is an own property of the object, false otherwise.

Example

var obj = { name: "Jane", age: 30 };
for (var key in obj) {
    if (obj.hasOwnProperty(key)) {
        Write(key + ": " + obj[key] + "<br>");
    }
}
// Outputs:
// name: Jane
// age: 30

Missing Object Statics

The following ES6 Object static methods are not available in SSJS:

Method Alternative
Object.keys(obj) Use for...in with hasOwnProperty
Object.values(obj) Use for...in with hasOwnProperty
Object.entries(obj) Use for...in with hasOwnProperty
Object.assign(target, ...src) Copy properties manually with a loop
Object.create(proto) Not available
Object.freeze(obj) Not available