Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This [0] is the only difference I am aware of. But I would love to hear someone talk about performance differences (if any).

[0]: http://stackoverflow.com/a/336868/712889



I actually got in an argument with someone on SO the other day who swore blind that the only was to declare a 'class' was using this pattern. Took a fiddle to shut him up.

I just don't get what it adds to your code apart from hiding simple function definitions in the visual trappings of a static helper object or closure. Javascript is already homogeneous enough without making it visually even more.


>> I just don't get what it adds to your code apart from hiding simple function definitions in the visual trappings of a static helper object or closure. Javascript is already homogeneous enough without making it visually even more.

What method do you use instead of the following, when creating namespaces?

var yourNamespace = {

    foo: function() {
    },

    bar: function() {
    }
};


Wait, I don't think that JavaScript is homogeneous, not in the least, for me it's really heterogeneous, I can look at 3 or 4 scripts developed by people of different skills and backgrounds and see it done in 3 or 4 completely different styles, visually and syntactically.

Did you messed up the wording over homogeneity?


I mean the syntax is homogeneous, I agree the styles in use today certainly aren't!


The one I mentioned above, you cannot conditionally create functions using function declarations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: