JavaScriptのベストプラクティス大会 jsEdu
When "jQuerying" and need to apply a selector several times put it into a var instead of doing $('#my-el')everytime. #jsEdu
2010-10-14 05:04:33use object literals & self-executing anonymous functions to protect namespace i.e. var you = (function(){ return { me: '...' } })(); #jsEdu
2010-10-14 05:18:57when one tweets about site X ranking high on google despite having poor javascript docs, the tweet itself feeds into the prob. #jsedu
2010-10-14 06:05:43Note To Self : Always create an object to store your js functions and variables. quit cluttering up that global namespace. #jsEdu
2010-10-14 06:27:44Write unobtrusive code so structure (HTML) style (CSS) and behavior (JavaScript) are separate. Then your code will degrade gracefully #jsEdu
2010-10-14 07:43:11ensure your page is functional before applying JavaScript. JavaScript should be then used to enhance the page - progress. enhancemnt #jsEdu
2010-10-14 08:11:06$$() returns an array of DOM elements that satisfy the passed CSS selector. #jsEdu
2010-10-14 08:11:58Use regular `for` loops to traverse an array, not `for...in` #jsEdu
2010-10-14 08:40:40When traversing an Object with a `for...in` loop remember to use `hasOwnProperty` to only include members from the actual object. #jsEdu
2010-10-14 08:43:10@tutsplus #jsEdu JavaScript best practice: Don't pollute global namespace, always declare variables with var keyword http://amzn.to/cy6LKI
2010-10-14 09:05:26If you want to use Date as a timer, call it with: var start = +new Date(); This will return a number and avoid conversions. #jsEdu
2010-10-14 09:52:54Pack your code up just like (function($){...})(window.YourCode) #jsEdu
2010-10-14 10:54:31Use a bitwise operator ~~ instead parseInt(number, 10) to parse a float number to int: console.log(~~5.85) #jsEdu
2010-10-14 10:54:59Avoid sync Ajax calls as it will wait for the request to return before continuing,while async mode runs the request in the background #jsEdu
2010-10-14 12:16:14Feature detect rather than browser detect--if(document.getElementById){}else{}-- #jsEdu
2010-10-14 15:57:14Use 'onclick' in anchors rather than javascript:pseudo #jsEdu
2010-10-14 15:58:44Better to use a square bracket notation when using/accesing object props #jsEdu
2010-10-14 16:03:30Always use a var to cache the array length in a for loop. for(var x=0, size = array.length; x<size;x+=1). #jsEdu
2010-10-14 16:24:11Always try 2 group all Js files into One & Compress dem when deployin to reduce file size, no. of http requests & hence loading time #jsEdu
2010-10-14 16:29:54If dealing with events/anonymous functions,keep reference to "this" in the outer function scope in a variable called "that"(if needed)#jsEdu
2010-10-14 17:24:38