Possible Duplicate:
What is the 'new' keyword in JavaScript?
creating objects from JS closure: should i use the “new” keyword?
See this code:
function friend(name) {
return { name: name };
}
var f1 = friend('aa');
var f2 = new friend('aa');
alert(f1.name); // -> 'aa'
alert(f2.name); // -> 'aa'
What's the difference between f1
and f2
?