Objects Flashcards
.keys
Static method returns array of object’s properties
* Enumerable keys only
Array of string-keyed property keys
Object.keys(obj)
.values()
Static method returns array of objects values
* Enumerable values only
Array of string-keyed property values
Object.values(obj)
.entries()
Static method returns array of property key-value pairs
* Enumerable values only
Array of string-keyed property key-value pairs
Object.entries(obj)
.assign()
Copies the values of all enumerable own properties from N
source objects to a target object
* Assigns properties, not copying or defining new ones
* Envokes getters & setters
The target object
Object.assign(target, ...sources)
.freeze()
Prevents an object from being modified
* Prevents extensions & makes exostomg properties non-writable and non-configurable.
* Cannot be changed
* Properties are made immutable
The object that was passed to the function
Object.freeze(obj)
.seal()
Prevents new properties from being added to an object and marks all existing properties as non-configurable
* Prevents extensions
* Static Method
* Makes the object have a fixed set of properties, but values can be mutated
The object being sealed
Object.seal(obj)
.is()
Compares two values to determine if they are the same value
* Static method
* Not like strict equality operator, b/c it treats signed zeros and Nan
differently
A boolean indicating whether or not the two arguments are the same value
Object.is(value1, value2)
.hasOwnProperty()
Returns a boolean indicating whether an object has a specific property as a direct property of that object
* As opposed to inheriting it
* Can be called on most JS objects, due to inheritice on most data structures
Returns true
if the object has the specified property
Object.prototype.hasOwnProperty(prop)
.create()
Creates a new object with a specified prototype object and properties
A new object with teh specified prototype object and properties
Object.create(proto)
.defineProperty()
Adds a new property to an object or modifies an exising one
* Properties added using this are not writable enumerable or configurable
* Research this one
The object that was passed to the function
Object.defineProperty(obj, prop, descriptor)