JavaScriptのベストプラクティス大会 jsEdu

詳細は"10 Free Copies of “JavaScript Patterns” from O’Reilly Books | Nettuts+" http://net.tutsplus.com/freebies/books/10-free-copies-of-javascript-patterns-from-oreilly-books/ 要は #jsEdu つけてJavaScriptのTips投稿してね。の検索メモ。 追記:一部取り出して日本語にしてみました。 続きを読む
13
前へ 1 ・・ 13 14 次へ
David Bories @yetdavid

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:33
Andy @ninjabiscuit

use object literals & self-executing anonymous functions to protect namespace i.e. var you = (function(){ return { me: '...' } })(); #jsEdu

2010-10-14 05:18:57
Aaron Heckmann @aaronheckmann

when 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:43
Mike Slater @slatron

Note 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:44
Moses @momosapian

Write unobtrusive code so structure (HTML) style (CSS) and behavior (JavaScript) are separate. Then your code will degrade gracefully #jsEdu

2010-10-14 07:43:11
Julian Josephs @jjosephs

ensure 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
Edan Tal @edan_Tal

$$() returns an array of DOM elements that satisfy the passed CSS selector. #jsEdu

2010-10-14 08:11:58
Peter Galiba @Poetro

Use regular `for` loops to traverse an array, not `for...in` #jsEdu

2010-10-14 08:40:40
Peter Galiba @Poetro

When 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
Jay Liew @jaysern

@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:26
ripter001 💎 @ripter001

If 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:54
Learning @liangyongning

Pack your code up just like (function($){...})(window.YourCode) #jsEdu

2010-10-14 10:54:31
Lucas Dsa. @lucaas_sda

Use a bitwise operator ~~ instead parseInt(number, 10) to parse a float number to int: console.log(~~5.85) #jsEdu

2010-10-14 10:54:59
Joey Kudish 🇺🇦🏳‍🌈 @jkudish

Avoid 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:14
Irving Dela Cruz @vingdc

Always use 'var' when creating variables #jsEdu

2010-10-14 15:55:15
Irving Dela Cruz @vingdc

Feature detect rather than browser detect--if(document.getElementById){}else{}-- #jsEdu

2010-10-14 15:57:14
Irving Dela Cruz @vingdc

Use 'onclick' in anchors rather than javascript:pseudo #jsEdu

2010-10-14 15:58:44
Irving Dela Cruz @vingdc

Better to use a square bracket notation when using/accesing object props #jsEdu

2010-10-14 16:03:30
salvitas.eth @salvixxx

Always 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:11
Kapil Raichana @imkapsicum

Always 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:54
Marko Srdoc @realitycrop

Javascript -> avoid Globals when possible #jsEdu

2010-10-14 16:50:50
BΞrnd @berndartmueller

If 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
前へ 1 ・・ 13 14 次へ