Part I of a presentation on Advanced Concepts in JavaScript. Cover topics like: objects, functions, closures, inheritance, new platform features, and much more.
Read more: http://luisatencio.net
JS was supposed to be Scheme for the web while at Netscape
Ran out of time, then they wanted to be more Java like
Guys wrote it in a week, basically
In javascript, every object has a constructor property that refers to the constructor function that initializes the object.
function MyConstructor() {}
var obj = new MyConstructor();
console.log(obj.constructor == MyConstructor); // true
When you declare a function: function Person() {}
The interpreter creates the new function object from your declaration. Together with the function, it’s prototype property is created and populated.
This prototype is an object with property constructor, which is set to the function itself.
MyConstructor.prototype = { constructor: MyConstructor }
A global variable ‘name’ will created in the global space
Constructor : references the constructor function used to create this object
Inside bar, !foo returns true because of var foo would hoist it to the top and set it to null