The first question I was asked in the interview, and to be honest I saw myself really confused and shown the door,
Consider the snippets:
Case a:
var sayHello = new Function("alert('Hello there');");
alert(sayHello instanceof Function); // true
alert(sayHello instanceof Object); // true, since every
// object inherits from Object
Case b:
var myFunction = function(){
}
var ins = new myFunction();
alert(ins instanceof myFunction); // ofcourse, true
alert(myFunction instanceof Function); // true
alert(ins instanceof Function); // false, Why is this not true?
As per my understanding, Function must be in the prototypical chain of ins?
ins <-- myFunction <-- Function <-- Object
insis not even a functioninsis an object, not a function, you can't callins()here :)myFunctionis a constructor function, callingnewon it creates a new object that is not a function.