I was playing with instanceof
in javascript and I stumbled upon the following.
Array instanceof Object
returns true
Object instanceof Array
returns false
What is the relationship between Array and Object here ?
Between the constructors, the relationship or prototype chain is:
Array -> Function.prototype -> Object.prototype
Object -> Function.prototype -> Object.prototype
The 1st is true
because a constructor is a Function
and functions are themselves Objects.
Array instanceof Function // true
Object instanceof Function // true
(function () {}) instanceof Object // true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With