JavaScriptのベストプラクティス大会 jsEdu
Always put the opening brace of an if statement, function, etc. on the same line as the beginning of the statement or declaration. #jsEdu
2010-10-13 00:03:31Declare variable outside the for statement which is used for each loop #jsEdu
2010-10-13 00:04:03Javascript the language for web mobile apps "JavaScript Patterns" from O'Reilly Books http://is.gd/fYJ4l #jsEdu
2010-10-13 00:04:05Avoid 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-13 00:05:14don't change variable's type after declaration ie. var test = "hello"; test = 10; #jsEdu
2010-10-13 00:06:37Try to do feature detection and not browser detection #jsEdu
2010-10-13 00:07:38When using forms you can do $("input[name='id']").val(); instead of always needing to put and id on the input tags. #jsEdu
2010-10-13 00:07:52When outputting HTML using JavaScript, always escape the forward slash ('/') by placing a backward slash ('\') in front of it. #jsEdu
2010-10-13 00:08:57Whenever possible, place scripts at the bottom of your page, not the top. Avoid blocking the DOM loading. #jsEdu
2010-10-13 00:09:33Always wrap your if-else statements in braces {}. Even if its only one operator in condition: if(..){...} else{...} #jsEdu
2010-10-13 00:10:00To speed up the pages render, put the scripts (when possible) at the bottom of body (JS scripts block parallel downloads). #jsEdu @nettuts
2010-10-13 00:10:13Use immediate invocations #javascript (function() { }()); #jsEdu
2010-10-13 00:10:47Always use an object literal -- {} -- instead of the new Object() constructor. #jsEdu
2010-10-13 00:10:59Use 'return this' when you want to chain methods of an object similar to jQuery. #jsEdu
2010-10-13 00:11:09Wrap code inside "for in" loops in hasOwnProperty() conditional 2 make sure u exclude properties from the prototype chain #jsEdu
2010-10-13 00:11:36Preferred way to declare objects and arrays: var person = {}, keys = []; #jsEdu
2010-10-13 00:12:13@nettuts always minimize your JavaScript (using compression tools like YUI compressor) on deployment & improve the page performance #jsEdu
2010-10-13 00:12:32parseInt on strings starting with 0 will not return what you expect. Try "01" through "0100" in a loop to see. #jsEdu #javascript
2010-10-13 00:13:38Create local copies of objects or functions used frequently in the body of a function to reduce the time required for name-lookups. #jsEdu
2010-10-13 00:15:06JavaScript is case sensitive | Use defer attrib. for IE scripts, Firefox 3.5 also supports | Use try-catch to prevent error display #jsEdu
2010-10-13 00:15:27Make sure to always comment your code. I need to understand it too! #jsEdu
2010-10-13 00:17:43declare all variables with "var" @ the start of every JavaScript function. #jsEdu
2010-10-13 00:18:48Live and Breath "JavaScript: The Good Parts" by Douglas Crockford. #jsEdu
2010-10-13 00:19:17With scoping and hositing, always declare your varialbes with a var statment, and that it be at the top of your function. #jsEdu
2010-10-13 00:19:31