<p>What are some good resources to learn best practices for Javascript?  I'm mainly concerned about when something should be an object vs. when it should just be tracked in the DOM.  Also I would like to better learn how to organize my code so it's easy to unit test.</p>

[{'answer_id': 39713, 'author': 'Cebjyre', 'author_id': 1612, 'author_profile': 'https://Stackoverflow.com/users/1612', 'pm_score': 2, 'selected': False, 'text': '<p>Probably the single most important thing is to use a framework, such as <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>, or <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">prototype</a>, to iron out the differences between browsers, and also make things easier in general.</p>\n'}, {'answer_id': 39723, 'author': 'slm', 'author_id': 4262, 'author_profile': 'https://Stackoverflow.com/users/4262', 'pm_score': 3, 'selected': False, 'text': '<p>I liked <a href="http://oreilly.com/catalog/9780596517748/" rel="nofollow noreferrer">JavaScript:The Good Parts</a> by Douglas Crockford although it\'s focused entirely on the language and ignores the DOM altogether.</p>\n'}, {'answer_id': 39907, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 1, 'selected': False, 'text': '<p>You can pick up a lot from <a href="https://rads.stackoverflow.com/amzn/click/com/1590597273" rel="nofollow noreferrer" rel="nofollow noreferrer">Pro JavaScript Techniques</a>, and I\'m looking forward to Resig\'s forthcoming <a href="http://jsninja.com/" rel="nofollow noreferrer">Secrets of the JavaScript Ninja</a>.</p>\n'}, {'answer_id': 39970, 'author': 'Ryan Doherty', 'author_id': 956, 'author_profile': 'https://Stackoverflow.com/users/956', 'pm_score': 6, 'selected': True, 'text': '<p>Seconding <a href="http://oreilly.com/catalog/9780596517748/" rel="noreferrer">Javascript: The Good Parts</a> and Resig\'s book <a href="http://jsninja.com/" rel="noreferrer">Secrets of the Javascript Ninja</a>.</p>\n\n<p>Here are some tips for Javascript:</p>\n\n<ul>\n<li>Don\'t pollute the global namespace (put all functions into objects/closures)\n\n<ul>\n<li>Take a look at <a href="http://developer.yahoo.com/yui/" rel="noreferrer">YUI</a>, it\'s a huge codebase with only 2 global objects: YAHOO and YAHOO_config</li>\n</ul></li>\n<li>Use the Module pattern for singletons (<a href="http://yuiblog.com/blog/2007/06/12/module-pattern/" rel="noreferrer">http://yuiblog.com/blog/2007/06/12/module-pattern/</a>)</li>\n<li>Make your JS as reusable as possible (jQuery plugins, YUI modules, basic JS objects.) Don\'t write tons of global functions.</li>\n<li>Don\'t forget to var your variables</li>\n<li>Use JSlint : <a href="http://www.jslint.com/" rel="noreferrer">http://www.jslint.com/</a></li>\n<li>If you need to save state, it\'s probably best to use objects instead of the DOM.</li>\n</ul>\n'}, {'answer_id': 500665, 'author': 'Thomas Kjørnes', 'author_id': 31491, 'author_profile': 'https://Stackoverflow.com/users/31491', 'pm_score': 3, 'selected': False, 'text': '<p>I disagree to the "use a framework" statement to some degree. Too many people use frameworks blindly and have little or no understanding of what\'s going on behind the curtains.</p>\n'}, {'answer_id': 500758, 'author': 'bobtorp', 'author_id': 51383, 'author_profile': 'https://Stackoverflow.com/users/51383', 'pm_score': 1, 'selected': False, 'text': '<p>As an addendum to the Crockford book, you may also want to check out this piece <a href="http://javascript.crockford.com/code.html" rel="nofollow noreferrer">Code Conventions for the Javascript Programming Language</a>. I also have a slightly different suggestion: instead of using a JS library off the bat, why not create your own? You may write a crappy library (as I did), but you\'ll learn something in the process. You have existing examples you can use as models. Also, to help give you an understanding of JS design patterns, I shall recommend another book, \'Pro Javascript Design Patterns\'. </p>\n'}, {'answer_id': 961243, 'author': 'dplante', 'author_id': 67097, 'author_profile': 'https://Stackoverflow.com/users/67097', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://developer.yahoo.com/yui/theater/" rel="nofollow noreferrer">YUI Theatre</a> has a bunch of videos (some with transcripts) by Steve Souders, Douglas Crockford, John Resig and others on JavaScript, YUI, website performance and other related topics.</p>\n\n<p>There are also very interested google tech talks on <a href="http://www.youtube.com" rel="nofollow noreferrer">Youtube</a> on jQuery and other frameworks.</p>\n'}, {'answer_id': 1540652, 'author': 'OscarRyz', 'author_id': 20654, 'author_profile': 'https://Stackoverflow.com/users/20654', 'pm_score': 2, 'selected': False, 'text': '<p>If you don\'t feel like reading you can watch this video: <a href="http://www.youtube.com/watch?v=hQVTIJBZook" rel="nofollow noreferrer">JavaScript the good parts by Doug Crockford</a>.</p>\n'}]
['https://Stackoverflow.com/questions/39691', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4114/']