What do you think?
Rate this book
201 pages, Kindle Edition
First published June 25, 2014
Consider:
function Foo() { /* ... */ }
Foo.prototype = { /* ... */ }; // create a new prototype object
var a1 = new Foo();
a1.constructor === Foo; // false!
a1.constructor === Object: // true!
Object(..) didn't "construct" a1, did it? It sure seems like Foo() "constructed" it. Most developers think of Foo() as doing the construction, but where everything fall apart is when you think "constructor" means "was constructed by," because by that reasoning, a1.constructor should be Foo, but it isn't!