I'm trying understand core javascript. it's little bit confusing. When I evaluate
Object instanceof Function
its true , and Function instanceof Object its also true.
How and why?
Becouse instanceof is evaluating Object and checking if this has as an instance of Function.constructor in its prototype chain, and reverse:
Function.__proto__.__proto__ // Object.prototype
Object.__proto__ // Function.prototype
Anyway, you have the full explanation on this answer.
Object is an instance of Function.
ObjectandFunctionboth refer to functions. Your question is confusing; you should re-read it.Object instanceof Functiontwice in your question.Objectand see what it returns.obj instanceof Funcworks. It simply checks whetherFunc.prototypeis inobj's prototype chain. SinceObjectis a function,Function.prototypeis in its prototype chain. SinceFunctionis an object (every function is an object),Object.prototypeis in its prototype chain.