What is the output of the following code: console.log([1, 2, 3] instanceof Array);?
a)
true
b)
false
c)
undefined
d)
null
Answer:
a)
true
Explanation:
The instanceof
operator checks if an object is an instance of a specific class. In this case, [1, 2, 3]
is an array, so the result of [1, 2, 3] instanceof Array
is true
.