function person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
var myFather = new person("John", "Doe", 50, "blue");
console.log(myFather instanceof person); //true
console.log(myFather instanceof Object); //true
console.log(myFather instanceof Function); //false
Hello, in this case, we created an object from the function constructor: 'person'.
Every function in JavaScript is an instance of the Function constructor. Why is myFather not an instance of Function?
myFather
is an object instance ofperson
that is why it is returning true formyFather instanceof Object
but false formyFather instanceof Function
as it is not a function but an object, you can't call myFather again to instantiate another object. Actuallyperson
is an instance of Function. When you callnew person
a plain object is returned and it is stored in myFather.