Answer the question
In order to leave comments, you need to log in
Why does it return false?
Here is the code:
function Func() {
this.name = 'Eva',
this.surname = 'Li'
};
console.log(Func.prototype == constructor.Func); //false
false
if the constructor function Func
really contains a property prototype
, which contains a property constructor
, which in turn contains a reference to the same constructor function Func
? Answer the question
In order to leave comments, you need to log in
Kerrik Sun , well, you can't not know (not understand) the language so much ...
You are referring to the variable constructor
. I suspect that you are doing this in the browser console and this variable was never declared, so JS will give you a property constructor
of the global object. In this case, it will be window.constructor
which, of course, has nothing to do with your Func function.
And in any case, constructor
it makes sense to look at an instance of an object, and not at a class.
let f = new Func();
console.log(f.constructor === Func) // true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question