JavaScriptのベストプラクティス大会 jsEdu
Don't try to be smart when debugging. Use copious logs/alerts to track down bugs. #jsEdu #javascript
2010-10-13 00:53:28default and guard operator: var foo = o || {};//init with empty obj if o is falsy var bar = o && o.bar;//if o is truthy, return o.bar #jsEdu
2010-10-13 00:56:51Use [] (e.g. var a = ['a','b']; ) instead of: new Array(); (e.g. var a = new Array(); a.push('a'); a.push('b');) #jsEdu
2010-10-13 01:04:0610 Free Copies of “JavaScript Patterns” from O’Reilly Books - http://tinyurl.com/32kuv3g) #jsEdu
2010-10-13 01:08:32Use a single 'var' statement to declare your scope variables #jsEdu
2010-10-13 01:09:03If one needs a DOM element's ID in jQuery, it makes no sense to do $(this).attr("id") -- you can just write this.id. More efficient! #jsEdu
2010-10-13 01:11:03Avoid using global variables in JavaScript, Instead go for the nested functions which are very reliable than global variables. #jsEdu
2010-10-13 01:14:28Global variables and functions are rarely required. Using globals may cause code to break. #jsEdu
2010-10-13 01:18:12the browser UI thread is responsible for rendering and evaluating js, move your js to the bottom to improve rendering speed #jsEdu
2010-10-13 01:21:49already improved page load performance with #yslow and #pagespeed? now use http://ajax.dynatrace.com/ to improve javascript perf #jsEdu
2010-10-13 01:24:13Accessing modified closures is what makes JavaScript so powerful. Make use of the 'this' keyword for scoping callback references. #jsEdu
2010-10-13 01:26:09In javascript, void is an operator that takes an operand and returns undefined. Avoid void #jsEdu
2010-10-13 01:28:01Put the http://promotejs.com badge on your blog #jsEdu
2010-10-13 01:33:36Always use 'var' when declaring variables in your objects to avoid polluting the global namespace #jsEdu
2010-10-13 01:34:33When creating classes in javascript, add your methods using [Class].prototype.[method] to load class definition only once. #jsEdu
2010-10-13 01:35:27Javascript Best Practice: Save your hairline and ALWAYS comment out EVERYTHING, EVERYWHERE. No excuses. #jsEdu
2010-10-13 01:36:54Javascript has two sets of equality operators: === and !==, & their evil twins == and !=. The good ones work the way you expect. #jsEdu
2010-10-13 01:38:39Discover different ways to define a function in JavaScript #jsEdu
2010-10-13 01:40:00using #jquery on IE 6 or 7? avoid selectors by classname only, as it will have to iterate the full dom. prefer id or tag #jsEdu
2010-10-13 01:40:08if u r on jquery for javascript,keep an eye on "return false" at the end of any function definition. missing that may cost you a lot. #jsEdu
2010-10-13 01:40:38undefined, unlike null or window, is not a reserved word and can be redefined #jsEdu
2010-10-13 01:43:33== and != do not match types. Don't dismiss them bc you haven't used them correctly in the past. #jsEdu #javascript
2010-10-13 01:43:40