Skip to content

API Object

Liu.Yandong.Hanks edited this page Aug 21, 2026 · 3 revisions

Object

Object creation plus comparison, copying, enumeration, and freezing utilities.

Script API Reference

Overview

Object creates ordinary objects and provides the utility helpers used to compare, copy, enumerate, and freeze them. Use the {} literal for ordinary objects; use the constructor when an object must be derived from an existing prototype.

Object is callable, so Object(prototype) and new Object(prototype) both produce an object.

Quick Reference

Member Returns Summary
Object([prototype]) object Creates an empty object, or one derived from the supplied object.
Object.equal$(left, right) boolean Strict object equality.
Object.equal(left, right) boolean Value equality for supported values.
Object.deepEqual(left, right) boolean Deep structural equality.
Object.assign(target, ...sources) object Copies enumerable properties into a target object.
Object.keys(value) string[] Enumerable property names.
Object.clone(value) any Shallow clone.
Object.deepClone(value) any Deep clone.
Object.extends(prototype) null Creates an object that extends a prototype. Not recommended.
Object.freeze(value) null Freezes an object to prevent mutation.
object.length number Number of enumerable members.
object.toString() string String representation.

Constructors

Object([prototype])

Parameters

Name Type Required Description
prototype object No Object to derive from.

Returns

object — an empty object, or an object derived from the supplied object.

Example

var base = { kind: "base" };
var item = new Object(base);
return item.kind; // "base"

Properties

object.length

Returns

number — the number of enumerable members.

Example

return ({ first: 1, second: 2 }).length; // 2

Methods

Object.equal$(left, right)

Parameters

Name Type Required Description
left any Yes First value in the comparison.
right any Yes Second value in the comparison.

Returns

boolean — the strict object equality result.

Example

var value = {};
return Object.equal$(value, value); // true

Object.equal(left, right)

Parameters

Name Type Required Description
left any Yes First value in the comparison.
right any Yes Second value in the comparison.

Returns

boolean — the value equality result for supported values.

Example

return Object.equal("aurora", "aurora"); // true

Object.deepEqual(left, right)

Parameters

Name Type Required Description
left any Yes First value in the comparison.
right any Yes Second value in the comparison.

Returns

boolean — the deep structural equality result.

Example

return Object.deepEqual({ id: 1 }, { id: 1 }); // true

Object.assign(target, ...sources)

Parameters

Name Type Required Description
target object Yes Object that receives the copied properties.
sources object Yes One or more source objects, passed as variadic arguments.

Returns

object — the same target.

Behavior

Copies enumerable properties from each source in order, so a later source overwrites an earlier one. target is mutated in place.

Example

var target = { a: 1 };
Object.assign(target, { b: 2 });
return target.b; // 2

Object.keys(value)

Parameters

Name Type Required Description
value object Yes Object to enumerate.

Returns

string[] — the enumerable property names.

Example

return Object.keys({ left: 1, right: 2 }).length; // 2

Object.clone(value)

Parameters

Name Type Required Description
value any Yes Value to shallow-clone.

Returns

any — a copy of the top level.

Behavior

Nested objects are shared with the original, not copied.

Example

var source = { nested: { value: 1 } };
var copy = Object.clone(source);
return copy.nested == source.nested; // true

Object.deepClone(value)

Parameters

Name Type Required Description
value any Yes Value to deep-clone.

Returns

any — an independent deep copy.

Example

var source = { nested: { value: 1 } };
var copy = Object.deepClone(source);
copy.nested.value = 2;
return source.nested.value; // 1

Object.extends(prototype)

Parameters

Name Type Required Description
prototype object Yes Prototype or object to extend.

Returns

null.

Caution

The current implementation does not return a usable derived object. Do not use Object.extends in production code; use Object(prototype) when an object must be derived from another object.

Example

var result = Object.extends({ kind: "base" });
return result; // do not rely on this result

Object.freeze(value)

Parameters

Name Type Required Description
value object Yes Object to freeze.

Returns

null.

Behavior

Prevents later mutation of the object. Apply it once shared configuration has been fully initialized.

Example

var settings = { enabled: true };
Object.freeze(settings);
return settings.enabled; // true

object.toString()

Parameters

None.

Returns

string — a string representation of the object.

Example

return ({ name: "Aurora" }).toString();

Clone this wiki locally