Quote:
Originally Posted by resetreset
What if there IS nothing defined as a prototype?
|
Then you can assume that "this" is {}.
This is probably the best information on the Javascript new keyword you can get for free:
https://developer.mozilla.org/en-US/.../Operators/new
You really should purchase a copy of "Javascript
: The Good Parts", which is my go-to book for things like this:
http://shop.oreilly.com/product/9780596517748.do
Quote:
Also, someone (in the know, ostensibly) told me that the code for foo WON'T be executed - it'll only be compiled, and executed later....?
|
I think there was a miscommunication involved. Foo is indeed executed, then its "this" is returned and assigned to x.
Yes, the entire code for the function is run when you call it with "new". I don't know why you or your friend would have thought otherwise.