This question already has an answer here:
var ninja = (function(){
function Ninja(){}
return new Ninja();
})();
I've been learning Javascript for a while now. Why is the function declaration encapsulated in '('s and also why is there a '();' in the end?
I can imagine its a constructor function, because of the '();' in the end. but why is the object wrapped in simple brackets?