Search⌘ K

Solution Review: "instanceof" Operator

Explore how to use the instanceof operator to test prototype chains and inheritance in JavaScript objects. This lesson helps you understand why certain instances return false results, by examining examples with Object.prototype and custom functions. Gain the skills needed to confidently answer questions about instanceof in frontend interviews.

Question 1: Solution review #

Explanation #

To answer this question, let’s see what the type of Object.prototype is.

Javascript (babel-node)
console.log(typeof(Object.prototype))

Is Object.prototype an instance of Object?

Javascript (babel-node)
console.log(Object.prototype instanceof Object)

The answer is ...