Possible Duplicate:
Javascript object creation using literals vs custom constructor functions
Function vs. Object Literal Notaion - Which is better, or is it a matter of preference?
Could anyone enlighten me what is the difference between below two ways of creating objects in JavaScript or more specifically drawbacks/advantages of them:
Function Foo() {
function bar () {...}
}
And
var Foo = {
bar : function() {}
}
Also since in latter way, there is no this keyword, how can I make it object instance member ?
new) while the second is an object literal with a function. Anyways, you'll havethisin the second bar function as well, not sure why you say that there isn't.Foois already an object, an instance so to speak.