Ask HN: How should you actually do objects in Javascript?
Are there any really good articles or examples about the best way(s) to create and use objects in Javascript?
2 comments
There's a lot of special rules here, though. "Effective Javascript", in the the objects chapter is the best guide I've read to understanding JS objects. A quick tip is to implement lightweight dictionaries as literal objects to avoid prototype pollution.
The best way is to add functions to the prototype. Also, here's a good article: http://www.phpied.com/3-ways-to-define-a-javascript-class/