I'm new to JavaScript coming from a Java background. I have difficulty understanding the following behavior.
console.log(Object.constructor.name); // prints Function.
console.log(Object instanceof Function); // prints true since Object's constructor is Function.
So that means Object is an instance of Function.
console.log(Function instanceof Object); // prints true
How can Function be an instance of Object if Object is an instance of Function?
I ran the code in the latest Google chrome browser.
prints true since Object's constructor is FunctionThat is not accurate. It prints true because Object's prototype is inherited from Function's prototype:Object._proto__ === Function.__proto__ //trueThey are both functions.1 instanceof Numberreturns false, etc...