3 ms·
This is a really terrible guide. I just skimmed it and found several major errors: 1. It's pretty well accepted that constructors should be capitalized. This i
by tlrobinson 16y ago
This is a really terrible guide. I just skimmed it and found several major errors:
1. It's pretty well accepted that constructors should be capitalized. This is a minor style problem compared to everything else.
2. The entire section on "freeing" objects is just wrong. Not going to bother explaining why.
3. This is wrong:
MyChildObject.prototype = MyParentObject.prototype;
Your entire inheritance tree will share a prototype, and adding a property to one constructor's prototype will add it to all of them, even the parents. You need to do something like "MyChildObject.prototype = new MyParentObject;" or "MyChildObject.prototype = Object.create(MyParentObject.prototype);"
4. The copying section contains a for-in loop without a obj.hasOwnProperty(name) guard.
- Tomek_ 16y ago"This is a really terrible guide." would be just enough to sum up this guide. If you're JavaScript newbie just skip it all along and spend that saved time on reading anything from someone like Douglas Crockford.
- natch 16y agoIt would be great if you would submit this feedback on the document using the link at the bottom. Based on personal experience, Apple fixes bad documentation when it is reported.
- gaoshan 16y agoSo if you are reading this and wondering "Then where can I get a decent style guide?" perhaps try this one instead: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml http://google-styleguide.googlecode.com/svn/trunk/javascript...