JavaScriptのベストプラクティス大会 jsEdu
Tweet a JS quick tip, and hash #jsEdu at the end to enter to win a copy of JavaScript Patterns. http://bit.ly/9xYHyW
2010-10-12 23:44:38Use auto-executing function -- (function(){ ... })() -- to simulate private functions and variables in Javascript #jsEdu
2010-10-12 23:44:37JavaScript versions of many useful PHP functions http://phpjs.org/ #jsEdu cc: @nettuts
2010-10-12 23:47:36You can use the following notation to create a javascript object: var car = { colour:'red', wheels:4} #jsEdu
2010-10-12 23:50:40Never bind JavaScript behavior to a link pointing to nothing (e.j. "#"). Always give links a real destination (graceful degradation) #jsEdu
2010-10-12 23:50:41Use 'e.preventDefault();' and/or 'e.stopPropagation();' instead of 'return false;' #jsEdu
2010-10-12 23:51:40Use {} instead of new Object() and [] instead of new Array() #jsEdu
2010-10-12 23:52:23@nettuts Avoid using the eval() function! #jsEdu --The 14th is my birthday also. Take that into account.
2010-10-12 23:52:39If you're interested in object-oriented JavaScript, check out my post: http://notes.conspirator.co/post/1269595708/oojs #jsEdu
2010-10-12 23:52:44@nettuts Learn to use http://www.jslint.com/ "it will hurt your feelings" ;-) #jsEdu
2010-10-12 23:52:47//JS shortcut for parseInt(): typeof parseInt('1') == typeof +'1' //true (number) #jsEdu
2010-10-12 23:53:41It's obvious but always indent your javascript code correctly. #jsEdu
2010-10-12 23:53:45Wrap your javascript code (i.e. jQuery plugins) in a self executing function to limit library collisions #jsEdu http://bit.ly/cnfzlm
2010-10-12 23:54:43Copy the link to the context of the outer function: "var that = this" and use "that" in closures to access parent function context #jsEdu
2010-10-12 23:55:22In your addressbar, javascript:location=document.referrer; Allows you to go back even when there's no back button. #jsEdu
2010-10-12 23:56:35Use the defer attribute for ie only external scripts #jsEdu
2010-10-12 23:56:42Always put your Javascript at the bottom of the page ! #jsEdu
2010-10-12 23:57:14Avoid using global variables! Use namespaces and follow the trend ;) #jsEdu @nettuts
2010-10-12 23:58:50use object literals and logical operators to suppress errors and check for namespaces (i.e. window.EDG = window.EDG || {};) #jsEdu
2010-10-12 23:59:17Eval is Evil http://bit.ly/9dXKjO http://bit.ly/dhlTk2 #jsEdu
2010-10-12 23:59:53Comment, comment, comment. Your code is only a view source away from anyone so educate and help them understand your mind. #jsEdu
2010-10-13 00:01:07Keep DOM lookup/access to a minimum, because it can be very expensive; cache elements that will be frequently used. #jsEdu
2010-10-13 00:03:22