Objects Flashcards

Get a fucking job

1
Q

What is an object?

A

A data type. Enclosed by curly braced and an n number of key:value pairs.

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

How can a property be accessed?

A
  1. Dot property accessor: object.property
  2. Square brackets property accessor: object[‘property’]
  3. Object destructuring: const {property} = object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is shorthand properties?

A

Whenever we have a variable which is the same name as a property of an object, when constructing the object, it can be omitted the property name.

function eg(name,id){
return {
name: name,
id: id,
timestamp: Date.now()
}
}

// SHORTHAND PROPERTIES

function eg(name,id){
return {
name,
id,
timestamp: Date.now()
}
}

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

What does the “in” operator do?

A

Returns true if the specified property is in the specified object or its prototype chain.

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

What is the prototype chain?

A

Every JavaScript object has an internal [[Prototype]] property. When accessing an object property, JavaScript first looks for it in the object itself. If it doesn’t find it, it will look for it in the prototype chain checking the object’s [[Prototype]]. The chain ends at Object.prototype whose [[Prototype]] is null.

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

What are dynamic properties?

A

The ability to add, modify or delete object properties at runtime.

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

What is destructuring?

A

A JavaScript expression that makes it possible to unpack values from arrays or properties from objects into distinct variables.

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

What is Object.values()?

A

Static method that returns an array of a given object’s own enumerable string-keyed property values.

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

What is Object.keys()?

A

Static method that returns an array of a given object’s own enumerable string-keyed property names.

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

What is Object.entries()

A

Static method that reutns an array of a give object’s own enumerable string-keyed property key-value pairs.

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

What is ??

A

Nullish coalescing operator. It’s a logical operator that returns its right-hand side when the left-hand side is null or undefined.

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

What is ?.

A

Optional chaining operator. If the object or function being accessed with this operator is null or undefined, the expression evaluates to undefined instead of throwing an error.

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

What is …

A

Spread syntax. Allows an iterable to be expanded in places in which zero or more arguments (for functions calls) or elements (for array literals) are expected.

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