Q
What is the output of const [a, b] = [1, 2];?

Answer & Solution

Answer: Option A
Solution:
Destructuring assignment allows extracting values from arrays and objects into distinct variables.
Related Questions on Average

What does the method Array.from() do?

A). Converts an array to a string

B). Converts an iterable or array-like object to an array

C). Clones an array

D). Filters an array

What does the for...of loop iterate over?

A). Object properties

B). Object values

C). Array indices

D). Iterable objects

What is the syntax for an arrow function in ES6?

A). function(a, b) { return a + b; }

B). (a, b) => { return a + b; }

C). (a, b) => a + b

D). Both B and C

What is the output of [...'hello']?

A). ['hello']

B). ['h', 'e', 'l', 'l', 'o']

C). [104, 101, 108, 108, 111]

D). ['h', 'e', 'll', 'o']

What is the output of typeof Symbol('description')?

A). 'string'

B). 'object'

C). 'symbol'

D). 'undefined'

What is the result of [...['a', 'b', 'c']]?

A). ['a', 'b', 'c']

B). [['a', 'b', 'c']]

C). ['abc']

D). Error

How do you interpolate variables in a string using template literals?

A). Hello, + name + '!'

B). Hello, ${name}!

C). 'Hello, ' + name + '!'

D). Both A and B

How do you check if a value is an array in ES6?

A). Array.isArray(value)

B). value.isArray()

C). value instanceof Array

D). typeof value === 'array'

What is the correct syntax to create a class in ES6?

A). class MyClass {}

B). class = MyClass {}

C). new MyClass = class {}

D). create class MyClass {}

How can you create a new promise in ES6?

A). new Promise(function)

B). Promise(function)

C). promise(function)

D). New Promise(function)