-
Notifications
You must be signed in to change notification settings - Fork 0
API Object
Object creation plus comparison, copying, enumeration, and freezing utilities.
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.
| 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. |
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"Returns
number — the number of enumerable members.
Example
return ({ first: 1, second: 2 }).length; // 2Parameters
| 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); // trueParameters
| 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"); // trueParameters
| 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 }); // trueParameters
| 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; // 2Parameters
| 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; // 2Parameters
| 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; // trueParameters
| 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; // 1Parameters
| 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 resultParameters
| 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; // trueParameters
None.
Returns
string — a string representation of the object.
Example
return ({ name: "Aurora" }).toString();AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License