What is the output of the following code: console.log([1, 2, 3] instanceof Array);?

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.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top