External: Object

Object

The built in Object object.
Source:
object.js, line 7
See:

Methods

assign(target, sources) → {Object}

The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. The Object.assign method only copies enumerable and own properties from a source object to a target object. It uses [[Get]] on the source and [[Put]] on the target, so it will invoke getters and setters. Therefore it assigns properties versus just copying or defining new properties. This may make it unsuitable for merging new properties into a prototype if the merge sources contain getters. For copying propertiy definitions, including their enumerability, into prototypes Object.getOwnPropertyDescriptor and Object.defineProperty should be used instead.
Parameters:
Name Type Description
target Object The target object.
sources Array.<Object> The source object(s).
Source:
object.js, line 65
See:
Returns:
The target object gets returned.
Type
Object
Example
// Merging objects
var o1 = { a: 1 };
var o2 = { b: 2 };
var o3 = { c: 3 };

var obj = Object.assign(o1, o2, o3);
console.log(obj);
// { a: 1, b: 2, c: 3 }

is(a, b) → {Boolean}

The Object.is() method determines whether two values are the same value.
Parameters:
Name Type Description
a Object The first value to compare
b Object The second value to compare
Source:
object.js, line 24
See:
Returns:
Type
Boolean
Example
// Strings are equal
var s = "foo";
Object.is(s, "foo"); //> true

// 0 and -0 are not equal
Object.is(0, -0); //>false

// NaN and NaN are equal
Object.is(NaN, NaN); //> true

// Two object references are not equal
Object.is({}, {}); //> false

// Two vars referencing one object are equal
var a = {}, b = a;
Object.is(a, b); //> true