var Person = function() {
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
};
console.log("called")
return Person;
}();
var p = new Person('John');
console.log('Person 1 name: ' + p.getName());
Here, Person is assigned something as (function(){}())
syntax, what is this syntax about and what is it doing, Please someone explain this...
I saw this code somewhere and I am not able to understand where the parenthesis after function syntax (function(){}()) came from and what are they doing.
On removing the second set of parenthesis it stops behaving as a constructor, Why so