Objects Flashcards

1
Q

.keys

A

Static method returns array of object’s properties
* Enumerable keys only

Array of string-keyed property keys

Object.keys(obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

.values()

A

Static method returns array of objects values
* Enumerable values only

Array of string-keyed property values

Object.values(obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

.entries()

A

Static method returns array of property key-value pairs
* Enumerable values only

Array of string-keyed property key-value pairs

Object.entries(obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

.assign()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

.freeze()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

.seal()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

.is()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

.hasOwnProperty()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

.create()

A

Creates a new object with a specified prototype object and properties

A new object with teh specified prototype object and properties

Object.create(proto)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

.defineProperty()

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly