Solution Review: "instanceof" Operator
In this lesson, we will discuss the solutions to the questions in the previous lesson.
Question 1: Solution review #
Explanation #
The instanceof
operator checks if an operand is an instance of the object passed on the right or of any of its ancestors in its prototype chain.
Run the code below:
Press + to interact
var names = ["Tom","Anna",2,true]console.log(names instanceof String)console.log(names instanceof Number)console.log(names instanceof Object)console.log(names instanceof Array)
From the output above, you can see that ...
Access this course and 1400+ top-rated courses and projects.