JS Built-in Objects Flashcards

1
Q

What is the global object in JavaScript?

A

JavaScript provides a global object which has a set of properties, functions and objects that are accessed globally, without a namespace.

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

List the global properties in JavaScript.

A

Infinity, NaN, undefined

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

List the global functions in JavaScript.

A

decodeURI(), decodeURIComponent(), encodeURI(), encodeURIComponent(), eval(), isFinite(), isNaN(), parseFloat(), parseInt()

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

List the global objects in JavaScript.

A

Array, Boolean, Date, Function, JSON, Math, Number, Object, RegExp, String, Symbol, and errors.

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

What does Infinity represent in JavaScript?

A

Infinity in JavaScript is a value that represents infinity.

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

How do you get negative infinity in JavaScript?

A

To get negative infinity, use the – operator: -Infinity.

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

What values are equivalent to positive and negative infinity?

A

Number.POSITIVE_INFINITY and Number.NEGATIVE_INFINITY

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

What happens when you add any number to Infinity, or multiply Infinity for any number?

A

It still gives Infinity.

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

What does NaN stand for?

A

Not a Number

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

What operations return NaN?

A

Operations such as zero divided by zero, invalid parseInt() operations, or other operations.

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

How do you check if a value evaluates to NaN?

A

You must use the isNaN() global function.

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

How do you check if a variable is undefined?

A

It’s common to use the typeof operator to determine if a variable is undefined.

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

What is the purpose of the decodeURI() function?

A

Performs the opposite operation of encodeURI()

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

What is the purpose of the decodeURIComponent() function?

A

Performs the opposite operation of encodeURIComponent()

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

What is the purpose of the encodeURI() function?

A

This function is used to encode a complete URL.

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

What characters does encodeURI() not encode?

A

It does encode all characters to their HTML entities except the ones that have a special meaning in a URI structure, including all characters and digits, plus those special characters: ~!@#$&*()=:/,;?+-_..

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

What is the purpose of the encodeURIComponent() function?

A

Instead of being used to encode an entire URI, it encodes a portion of a URI.

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

What characters does encodeURIComponent() not encode?

A

It does encode all characters to their HTML entities except the ones that have a special meaning in a URI structure, including all characters and digits, plus those special characters: _.!~*’()

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

What does the eval() function do?

A

This is a special function that takes a string that contains JavaScript code, and evaluates / runs it.

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

Why is the eval() function rarely used?

A

It can be dangerous.

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

What does the isFinite() function return?

A

Returns true if the value passed as parameter is finite.

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

What does the isNaN() function return?

A

Returns true if the value passed as parameter evaluates to NaN.

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

What is the purpose of the parseFloat() function?

A

Like parseInt(), parseFloat() is used to convert a string value into a number, but retains the decimal part.

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

What is the purpose of the parseInt() function?

A

This function is used to convert a string value into a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the second parameter of the parseInt() function?
The radix, always 10 for decimal numbers, or the conversion might try to guess the radix and give unexpected results.
26
What does parseInt() return if the string does not start with a number?
NaN (Not a Number)
27
What are the three ways to create an object in JavaScript?
Object literal syntax (const person = {}), Object global function (const person = Object()), Object constructor (const person = new Object())
28
What is the result of `typeof {}`?
object
29
What are static methods in the Object object?
Methods called directly on Object, not on an object instance.
30
What are instance methods in the Object object?
Methods called on an object instance.
31
What are the two properties of the Object object?
length (always 1) and prototype
32
What does `Object.assign()` do?
Copies all enumerable own properties from one or more objects to a target object (shallow copy).
33
What does `Object.create()` do?
Creates a new object with the specified prototype.
34
What does `Object.defineProperties()` do?
Creates or modifies multiple object properties at once.
35
What does `Object.defineProperty()` do?
Creates or modifies a single object property.
36
What does `Object.entries()` do?
Returns an array of an object's enumerable property [key, value] pairs.
37
What does `Object.freeze()` do?
Freezes an object, preventing new properties from being added and existing properties from being removed or changed.
38
What does `Object.getOwnPropertyDescriptor()` do?
Returns a property descriptor for a named property on an object.
39
What does `Object.getOwnPropertyDescriptors()` do?
Returns all own property descriptors of an object.
40
What does `Object.getOwnPropertyNames()` do?
Returns an array of all own property names of an object, including non-enumerable properties.
41
What does `Object.getOwnPropertySymbols()` do?
Returns an array of all own Symbol property keys of an object.
42
What does `Object.getPrototypeOf()` do?
Returns the prototype (internal [[Prototype]]) of the specified object.
43
What does `Object.is()` do?
Determines whether two values are the same value.
44
What does `Object.isExtensible()` do?
Determines if an object is extensible (whether it can have new properties added to it).
45
What does `Object.isFrozen()` do?
Determines if an object is frozen.
46
What does `Object.isSealed()` do?
Determines if an object is sealed.
47
What does `Object.keys()` do?
Returns an array of a given object's own enumerable property names.
48
What does `Object.preventExtensions()` do?
Prevents new properties from ever being added to an object.
49
What does `Object.seal()` do?
Prevents new properties from being added to an object and marks all existing properties as non-configurable.
50
What does `Object.setPrototypeOf()` do?
Sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to a new prototype or null.
51
What does `Object.values()` do?
Returns an array of a given object's own enumerable property values.
52
What does `hasOwnProperty()` do?
Returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it).
53
What does `isPrototypeOf()` do?
Returns a boolean indicating whether the object specified as the prototype of another object.
54
What does `propertyIsEnumerable()` do?
Returns a boolean indicating whether the specified property is enumerable and is the object's own property.
55
What does `toLocaleString()` do?
Returns a locale-sensitive string representation of the object.
56
What does `toString()` do?
Returns a string representation of the object.
57
What does `valueOf()` do?
Returns the primitive value of the specified object.
58
What is a property descriptor object?
An object that defines a property's behavior and attributes.
59
What are the properties of a property descriptor object?
value, writable, configurable, enumerable, get, set
60
What does the `writable` property of a descriptor do?
Determines if the property's value can be changed.
61
What does the `configurable` property of a descriptor do?
Determines if the property can be removed or its attributes changed.
62
What does the `enumerable` property of a descriptor do?
Determines if the property appears in enumerations of the object's properties.
63
What is the difference between `Object.freeze()` and `Object.seal()`?
`Object.freeze()` makes properties non-writable and non-configurable, while `Object.seal()` only prevents adding or removing properties.
64
What is the difference between `Object.preventExtensions()` and `Object.seal()`?
`Object.preventExtensions()` prevents adding new properties, while `Object.seal()` also prevents deleting existing properties.
65
What is the difference between `Object.keys()` and `Object.getOwnPropertyNames()`?
`Object.keys()` returns only enumerable property names, while `Object.getOwnPropertyNames()` returns all property names, including non-enumerable.
66
What is a shallow copy?
A copy where primitive values are cloned, but object references are copied (not the objects themselves).
67
How to check if an object is extensible?
Using Object.isExtensible()
68
How to check if an object is frozen?
Using Object.isFrozen()
69
How to check if an object is sealed?
Using Object.isSealed()
70
How do you create a number value using literal syntax?
const age = 36
71
How do you create a number value using the Number global function?
const age = Number(36)
72
What is the result of using the 'new' keyword with the Number function (e.g., new Number(36))?
A Number object is created.
73
How do you get the primitive number value from a Number object?
Using the valueOf() method.
74
What is Number.EPSILON?
The smallest interval between two representable numbers.
75
What is Number.MAX_SAFE_INTEGER?
The maximum safe integer value in JavaScript.
76
What is Number.MAX_VALUE?
The maximum positive representable value in JavaScript.
77
What is Number.MIN_SAFE_INTEGER?
The minimum safe integer value in JavaScript.
78
What is Number.MIN_VALUE?
The minimum positive representable value in JavaScript.
79
What is Number.NaN?
A special value representing 'Not-a-Number'.
80
What is Number.NEGATIVE_INFINITY?
A special value representing negative infinity.
81
What is Number.POSITIVE_INFINITY?
A special value representing positive infinity.
82
What does Number.isNaN(value) do?
Returns true if the value is NaN, false otherwise.
83
What does Number.isFinite(value) do?
Returns true if the value is a finite number, false otherwise.
84
What does Number.isInteger(value) do?
Returns true if the value is an integer, false otherwise.
85
What does Number.isSafeInteger(value) do?
Returns true if the value is a safe integer, false otherwise.
86
What does Number.parseFloat(value) do?
Parses a string and returns a floating-point number.
87
What does Number.parseInt(value) do?
Parses a string and returns an integer.
88
What is a safe integer in JavaScript?
An integer that can be represented exactly as an IEEE-754 double-precision number.
89
What does .toExponential() do (instance method)?
Returns a string representing the number in exponential notation.
90
What does .toFixed() do (instance method)?
Returns a string representing the number in fixed-point notation.
91
What does .toLocaleString() do (instance method)?
Returns a string with a language-sensitive representation of the number.
92
What does .toPrecision() do (instance method)?
Returns a string representing the number to a specified precision.
93
What does .toString() do (instance method)?
Returns a string representation of the number in a specified radix.
94
What does .valueOf() do (instance method)?
Returns the primitive number value of a Number object.
95
What value does Number.NaN return for 0 / 0?
true
96
What is the default locale for toLocaleString() method?
US English
97
What is the default radix for Number.parseInt()?
10
98
What is the result of `typeof new Number(36)`?
object
99
What is the result of `typeof Number(36)`?
number
100
What is the static method of the String object used to create a string from Unicode characters?
String.fromCodePoint()
101
What does String.fromCodePoint(70, 108, 97, 118, 105, 111) return?
'Flavio'
102
What does charAt(i) do?
Returns the character at index i.
103
What does charCodeAt(i) do?
Returns the Unicode 16-bit integer representing the character at index i.
104
What does codePointAt(i) do?
Returns the Unicode code point value at index i, handling characters outside the BMP.
105
What does concat(str) do?
Concatenates the current string with str.
106
What does endsWith(str) do?
Checks if a string ends with the value of str.
107
What does includes(str) do?
Checks if a string includes the value of str.
108
What does indexOf(str) do?
Returns the index of the first occurrence of str, or -1 if not found.
109
What does lastIndexOf(str) do?
Returns the index of the last occurrence of str, or -1 if not found.
110
What does localeCompare() do?
Compares a string to another according to locale, returning a number indicating their order.
111
What does match(regex) do?
Matches a string against a regular expression.
112
What does normalize() do?
Returns the string normalized according to a Unicode normalization form.
113
What does padEnd() do?
Pads the string with another string until it reaches a specified length, at the end.
114
What does padStart() do?
Pads the string with another string until it reaches a specified length, at the beginning.
115
What does repeat() do?
Repeats the string a specified number of times.
116
What does replace(str1, str2) do?
Replaces the first occurrence of str1 with str2, or all occurrences if using a global regex.
117
What does search(str) do?
Returns the index of the first match of str, or -1 if not found.
118
What does slice(begin, end) do?
Returns a new string from the portion between begin and end.
119
What does split(separator) do?
Splits a string into an array of substrings using the separator.
120
What does startsWith(str) do?
Checks if a string starts with the value of str.
121
What does substring(begin, end) do?
Returns a portion of a string between begin and end, handling negative indices differently than slice().
122
What does toLocaleLowerCase() do?
Returns a new string in lowercase according to locale.
123
What does toLocaleUpperCase() do?
Returns a new string in uppercase according to locale.
124
What does toLowerCase() do?
Returns a new string in lowercase.
125
What does toString() do?
Returns the string representation of the String object.
126
What does toUpperCase() do?
Returns a new string in uppercase.
127
What does trim() do?
Returns a new string with whitespace removed from both ends.
128
What does trimEnd() do?
Returns a new string with whitespace removed from the end.
129
What does trimStart() do?
Returns a new string with whitespace removed from the beginning.
130
What is the difference between charCodeAt() and codePointAt()?
charCodeAt() returns a 16-bit Unicode unit, while codePointAt() returns the full code point, handling characters outside the BMP.
131
How do you replace all occurrences of a string using replace()?
Use a regular expression with the global flag (/g).
132
What happens if charAt() is called with an index that does not exist?
An empty string is returned.
133
What does String.fromCodePoint(0x46, 0154, parseInt(141, 8), 118, 105, 111) return?
'Flavio'
134
What is the difference between substring() and slice() when dealing with negative indexes?
substring() treats negative indexes as 0, while slice() counts from the end.
135
What is the default normalization form for normalize()?
NFC
136
What is the alias of trimEnd()?
trimRight()
137
What is the alias of trimStart()?
trimLeft()
138
What is Math.E?
The base of the natural logarithm (approximately 2.71828).
139
What is Math.LN10?
The natural logarithm of 10.
140
What is Math.LN2?
The natural logarithm of 2.
141
What is Math.LOG10E?
The base 10 logarithm of e.
142
What is Math.LOG2E?
The base 2 logarithm of e.
143
What is Math.PI?
The mathematical constant π (approximately 3.14159).
144
What is Math.SQRT1_2?
The reciprocal of the square root of 2.
145
What is Math.SQRT2?
The square root of 2.
146
Are Math object methods static or instance methods?
Static methods.
147
What does Math.abs(x) do?
Returns the absolute value of x.
148
What does Math.acos(x) do?
Returns the arccosine of x (in radians).
149
What does Math.asin(x) do?
Returns the arcsine of x (in radians).
150
What does Math.atan(x) do?
Returns the arctangent of x (in radians).
151
What does Math.atan2(y, x) do?
Returns the arctangent of the quotient of its arguments (y/x).
152
What does Math.ceil(x) do?
Rounds x up to the nearest integer.
153
What does Math.cos(x) do?
Returns the cosine of x (in radians).
154
What does Math.exp(x) do?
Returns e raised to the power of x.
155
What does Math.floor(x) do?
Rounds x down to the nearest integer.
156
What does Math.log(x) do?
Returns the natural logarithm (base e) of x.
157
What does Math.max(x1, x2, ...) do?
Returns the largest of zero or more numbers.
158
What does Math.min(x1, x2, ...) do?
Returns the smallest of zero or more numbers.
159
What does Math.pow(x, y) do?
Returns x raised to the power of y.
160
What does Math.random() do?
Returns a pseudorandom number between 0 and 1.
161
What does Math.round(x) do?
Returns the value of x rounded to the nearest integer.
162
What does Math.sin(x) do?
Returns the sine of x (in radians).
163
What does Math.sqrt(x) do?
Returns the square root of x.
164
What does Math.tan(x) do?
Returns the tangent of x (in radians).
165
What is the range of values accepted by Math.acos() and Math.asin()?
-1 to 1.
166
What is the return unit of trigonometric functions like Math.cos(), Math.sin(), Math.tan(), Math.acos(), Math.asin(), and Math.atan()?
Radians.
167
What kind of number does Math.random() return?
A pseudorandom floating-point number between 0 (inclusive) and 1 (exclusive).
168
What is JSON?
A file format used to store and interchange data in key-value pairs.
169
Is JSON human-readable?
Yes.
170
How are keys represented in JSON?
Wrapped in double quotes.
171
What separates a key and its value in JSON?
A colon (:).
172
What separates key-value pairs in JSON?
A comma (,).
173
Does spacing matter in a JSON file?
No.
174
In what year was JSON born?
2002
175
What is the MIME type for JSON files?
application/json.
176
What are the basic data types supported by JSON?
Number, String, Boolean, Array, Object, null.
177
How are strings represented in JSON?
Wrapped in double quotes.
178
How are arrays represented in JSON?
Wrapped in square brackets ([]).
179
How are objects represented in JSON?
Wrapped in curly brackets ({}).
180
What does the null keyword represent in JSON?
An empty value.
181
What JavaScript object provides methods for encoding and decoding JSON?
The JSON object.
182
What method is used to parse a JSON string into a JavaScript object?
JSON.parse().
183
What method is used to convert a JavaScript object into a JSON string?
JSON.stringify().
184
What is the purpose of the optional second argument in JSON.parse()?
It's a reviver function used to perform custom operations during parsing.
185
How can you represent nested objects in JSON?
By including objects within other objects or arrays.
186
How are boolean values represented in JSON?
true or false (lowercase).
187
How are numbers represented in JSON?
Without quotes.
188
What standard defines JSON?
ECMA-404.
189
What file extension is commonly used for JSON files?
.json
190
How do you initialize a Date object representing the current time?
new Date()
191
What unit of time does the Date object use internally?
Milliseconds since January 1, 1970 (UTC).
192
How do you create a Date object from a UNIX timestamp?
new Date(timestamp * 1000)
193
What does new Date(0) represent?
January 1, 1970 00:00:00 UTC.
194
How does the Date object handle strings passed to its constructor?
It uses the parse method.
195
What does Date.parse('2018-07-22') return?
A timestamp (milliseconds).
196
How do you create a Date object using year, month, and day parameters?
new Date(year, month, day)
197
What is the minimum number of parameters for a Date constructor with year, month, etc.?
3 (year, month, day)
198
How are months numbered in the Date object?
Starting from 0 (January is 0).
199
How do you specify a timezone when initializing a Date object?
By adding '+HOURS' or '(Timezone Name)' to the date string.
200
What happens if you specify a wrong timezone name?
JavaScript defaults to UTC without error.
201
What does Date.now() return?
The current timestamp in milliseconds.
202
What does Date.UTC(2018, 6, 22) return?
A timestamp in milliseconds representing July 22, 2018 UTC.
203
What does date.toString() return?
A string representation of the date and time.
204
What does date.toUTCString() return?
A string representation of the date and time in UTC.
205
What does date.toISOString() return?
A string representation of the date and time in ISO 8601 format.
206
What does date.getTime() return?
The timestamp in milliseconds.
207
What does date.getDate() return?
The day of the month.
208
What does date.getDay() return?
The day of the week (0-6, Sunday is 0).
209
What does date.getFullYear() return?
The full year.
210
What does date.getMonth() return?
The month (0-11).
211
What does date.getHours() return?
The hours.
212
What does date.getMinutes() return?
The minutes.
213
What does date.getSeconds() return?
The seconds.
214
What does date.getMilliseconds() return?
The milliseconds.
215
What does date.getTimezoneOffset() return?
The timezone difference in minutes.
216
What is the difference between get* and getUTC* methods?
get* methods return values based on the local timezone, getUTC* methods return UTC values.
217
What methods are used to edit a Date object?
setDate(), setFullYear(), setMonth(), setHours(), setMinutes(), setSeconds(), setMilliseconds(), setTime()
218
What is the deprecated method to set the year?
setYear()
219
How do you get the timestamp in seconds from Date.now()?
Math.floor(Date.now() / 1000)
220
What is the unary operator that can be used to get the timestamp?
+
221
What happens if you overflow a month with the days count?
The date will go to the next month.
222
What object is used to format dates according to the locale?
Intl.DateTimeFormat()
223
How do you compare two dates?
By comparing their getTime() values.
224
How do you check if two dates are equal?
By comparing their getTime() values.
225
How do you determine if a Date object represents today?
By comparing getDate(), getMonth(), and getFullYear() with today's date.
226
What are the four ways to create a new Date object?
No parameters (now), number (milliseconds), string (date), parameters (parts of date).
227
What does date.toLocaleTimeString() return?
A string with a language-sensitive representation of the time portion of this date.
228
What does date.toLocaleString() return?
A string with a language-sensitive representation of this date.
229
What is the Intl object in JavaScript?
A built-in object that provides language-sensitive string comparison, number formatting, date and time formatting, and more.
230
What properties does the Intl object expose?
Intl.Collator, Intl.DateTimeFormat, Intl.NumberFormat, Intl.PluralRules, Intl.RelativeTimeFormat.
231
What method does the Intl object provide?
Intl.getCanonicalLocales().
232
What does Intl.getCanonicalLocales() do?
Checks if a locale is valid and returns the correctly formatted locale.
233
What happens if Intl.getCanonicalLocales() is passed an invalid locale?
It throws a RangeError.
234
How can you handle an invalid locale error?
Using a try/catch block.
235
Which String prototype method interfaces with the Intl API?
String.prototype.localeCompare().
236
Which Number prototype method interfaces with the Intl API?
Number.prototype.toLocaleString().
237
Which Date prototype methods interface with the Intl API?
Date.prototype.toLocaleString(), Date.prototype.toLocaleDateString(), Date.prototype.toLocaleTimeString().
238
What does Intl.Collator provide?
Language-sensitive string comparison.
239
How do you initialize a Collator object?
new Intl.Collator(locale).
240
What method is used to compare strings with a Collator object?
compare().
241
What does the compare() method return?
A positive, negative, or zero value indicating the order of the strings.
242
What does Intl.DateTimeFormat provide?
Language-sensitive date and time formatting.
243
How do you initialize a DateTimeFormat object?
new Intl.DateTimeFormat(locale).
244
What method is used to format a date with a DateTimeFormat object?
format().
245
What does the formatToParts() method return?
An array with all the date parts.
246
What does Intl.NumberFormat provide?
Language-sensitive number formatting, including currency.
247
How do you initialize a NumberFormat object for currency?
new Intl.NumberFormat(locale, { style: 'currency', currency: 'XXX' }).
248
What property is used to set the minimum number of fraction digits in NumberFormat?
minimumFractionDigits.
249
What does Intl.PluralRules provide?
Language-sensitive plural formatting and plural language rules.
250
How do you initialize a PluralRules object?
new Intl.PluralRules(locale, { type: 'ordinal' }).
251
What method is used to select the plural form with a PluralRules object?
select().
252
What are some practical usages of Intl.PluralRules?
Giving a suffix to ordered numbers (e.g., 1st, 2nd, 3rd).
253
What is the use of Intl.RelativeTimeFormat?
"provides language-sensitive relative time formatting"
254
What is a Set in JavaScript?
A collection of unique values.
255
How do you initialize a Set?
new Set()
256
How do you add an item to a Set?
set.add(value)
257
Does a Set allow duplicate values?
No.
258
How do you check if a Set contains an item?
set.has(value)
259
How do you delete an item from a Set?
set.delete(value)
260
How do you find the number of items in a Set?
set.size
261
How do you delete all items from a Set?
set.clear()
262
How do you iterate over the items in a Set?
Using set.keys(), set.values(), set.entries(), set.forEach(), or a for...of loop.
263
How do you initialize a Set with values?
new Set([value1, value2, ...])
264
How do you convert a Set to an array?
[...set.keys()] or [...set.values()]
265
What is a Map in JavaScript?
A collection of key-value pairs.
266
How do you initialize a Map?
new Map()
267
How do you add an item to a Map?
map.set(key, value)
268
How do you get an item from a Map?
map.get(key)
269
Does a Map allow duplicate keys?
No.
270
Does a Map allow duplicate values?
Yes.
271
How do you delete an item from a Map?
map.delete(key)
272
How do you delete all items from a Map?
map.clear()
273
How do you check if a Map contains an item by key?
map.has(key)
274
How do you find the number of items in a Map?
map.size
275
How do you initialize a Map with values?
new Map([[key1, value1], [key2, value2], ...])
276
Can objects be used as keys in a Map?
Yes.
277
What does map.get(nonExistentKey) return?
undefined
278
How do you iterate over the keys of a Map?
Using map.keys() and a for...of loop.
279
How do you iterate over the values of a Map?
Using map.values() and a for...of loop.
280
How do you iterate over the key-value pairs of a Map?
Using map.entries() or map directly in a for...of loop.
281
How do you convert the keys of a Map to an array?
[...map.keys()]
282
How do you convert the values of a Map to an array?
[...map.values()]