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 2 3 ・・ 15 次へ
Roger Wakeman @rgrwkmn

Use anonymous functions in setTimeout and setInterval instead of named functions or strings for more flexible scope. #jsEdu #javascript

2010-10-13 00:22:55
Dean Peterson @dpeterson_1

Wrap your JavaScript code in a function to localize variables. #jsEdu

2010-10-13 00:23:12
Jeremy Clements @jeremy_clements

Try not to use myVar.length as the conditional statement in for loops, because it will need to be calculated every time. #jsEdu

2010-10-13 00:23:39
Dean Peterson @dpeterson_1

Use the Object Literal pattern to organize your JavaScript code. var obj ={method:function(){},method:function(){}}; #jsEdu

2010-10-13 00:25:00
Hector Benitez @HectorBenitez

Variables in javascript either have global scope or function scope, always use the 'var' keyword to control this #jsEdu

2010-10-13 00:25:12
Václav Boháč @vaclavbohac

Use Object.prototype.hasOwnProperty.call(yourObject, i) in for-in loop. You can prevent bugs with extending built-in types. #jsEdu

2010-10-13 00:26:26
@matthiaswh

JS Best Practices: comment your code! You'll appreciate this later. Use === rather than ==. And use external files. #jsEdu cc @nettuts

2010-10-13 00:27:24
Jeremy McPeak @jwmcpeak

Specify the radix when calling parseInt() and parseFloat(). Otherwise, you may experience inconsistent results. #jsEdu

2010-10-13 00:29:19
Peter Wooley @peterwooley

In JavaScript, always declare your variables with "var" to avoid scoping confusion. #jsEdu

2010-10-13 00:29:56
🇩🇴 Junior Hernández @junihh

Shorthands is better. "var name = []" is more simple than "var name = new array ()" #jsEdu

2010-10-13 00:34:21
Nikki @nicolahibbert

Use a document fragment to append multiple elements to the page at once. One reflow rather than many = a big performance boost #jsEdu

2010-10-13 00:34:27
Jeremy McPeak @jwmcpeak

The DOM is slow. Limit your interaction with it (especially if your changes require a repaint or reflow). #jsEdu

2010-10-13 00:35:34
CyberSpektre @CyberSpektre

Always declare your variables outside of the for statement #jsEdu

2010-10-13 00:37:04
Jeremy McPeak @jwmcpeak

Use event delegation instead of assigning event handlers to multiple elements. #jsEdu

2010-10-13 00:37:21
Romain Ruetschi @_romac

Wrap your code in an auto-executing function to localize your variables.( function( $ ) { /* Code */ } )( jQuery ); #jsEdu

2010-10-13 00:39:22
Jose Marmolejos @SuMajestadJose

@junihh it might be quicker to type, but it's less legible #jsEdu

2010-10-13 00:40:04
🇩🇴 Junior Hernández @junihh

More performance ?? don't forget this: "var array_total = arrayname.length" to use it with "for". #jsEdu

2010-10-13 00:41:42
Diogo Resende @dresende

Always avoid using uppercase letters in variable/object/function names. Javascript is CASE SENSITIVE! #jsEdu

2010-10-13 00:43:21
Glenn Stovall @GSto

getElementbyID will also match elements by name in IE. be careful about that to avoid compatibility problems #jsEdu

2010-10-13 00:43:57
Jeremy McPeak @jwmcpeak

Objects can be used as hash tables. obj["myMethod"](); is the same as obj.myMethod(). #jsEdu

2010-10-13 00:45:10
Seungjin Kim (@seungjin@mstd.seungjin.net) @seungjin

Always use an object literal -- {} -- instead of the new Object() contructor. #jsEdu

2010-10-13 00:47:18
Dean Peterson @dpeterson_1

Search for #jsEdu in twitter for a great collection of JavaScript best practices tips :-)

2010-10-13 00:47:41
Anders Ringqvist @anddoutoi

Sweet shortcuts: +operator converts to number, !! converts to boolean: var foo='42';console.log(typeof foo,typeof +foo,typeof !!foo); #jsEdu

2010-10-13 00:47:58
Ariel Mariani @arielmariani

Alway try to use CamelCased variables when writting Javascript #jsEdu

2010-10-13 00:48:34
前へ 1 2 3 ・・ 15 次へ