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 ・・ 4 5 ・・ 15 次へ
Rob Friesel @founddrama

to ensure your function *actually* returns a Boolean, use the double-bang (e.g., return !!name;) #jsEdu

2010-10-13 01:44:32
Martijn Duizendstra @martijn1k

Include scripts dynamic, inject or use defer/async in <script tags to prevent JS files from blocking the browser rendering the page. #jsEdu

2010-10-13 01:45:40
saumya @saumya

Making IE html5 compatible, html5shim - http://goo.gl/AYbS #jsEdu

2010-10-13 01:51:56
Derek B @KrunchMuffin

Javascript tip - Avoid 'eval' - If it exists in your page, there is almost always a more correct way to accomplish what you are doing #jsEdu

2010-10-13 01:52:33
Svilen Popov @sgpopov

shortcut notations keep your code snappy and easier to read once you got used to it #jsEdu

2010-10-13 01:52:59
John McCaffrey @j_mccaffrey

want better js? write js unit tests. tons of great tools out there. Start by looking at how your favorite framework tests itself #jsEdu

2010-10-13 01:53:25
andrewpace @andrewpace

Reference form and their elements correctly: document.forms["formname"].elements["inputname"], not document.formname.inputname #jsEdu

2010-10-13 01:55:00
Roger Wakeman @rgrwkmn

example: `(!variable)` will be true for null, false, undefined, '' and 0. Useful and dangerous. #jsEdu #javascript

2010-10-13 01:55:25
Peter Anglea @peteranglea

#javascript formula for determining number of days in a month: var numdays = 32 - new Date([year], [month], 32).getDate(); #jsEdu

2010-10-13 01:57:04
David Pronk @pronkert

Always use option objects for optional arguments instead of loose arguments when calling a function {loop: false, duration: 200} #jsEdu

2010-10-13 01:57:09
Claudio Ortolina @cloud8421

Always better to group variable declarations like var a, b; if you need to assign a value, check the scope! #jsEdu

2010-10-13 01:59:37
stagas @stagas

Use var arr=['a','multiline','paragraph']; arr.push('another line'); and then arr.join('\n'); or arr.join('<br />'); to combine them #jsEdu

2010-10-13 02:00:41
Lucas Dsa. @lucaas_sda

Use a bitwise operator -- ~~ -- instead parseInt(number, 10) to parse a float number to int. #jsEdu

2010-10-13 02:03:28
Francois-Guillaume Ribreau @FGRibreau

function plop(super){alert(super);} Works fine in FF but will throw an error in Safari/Chrome. Because "super" is a reserved word • #jsEdu

2010-10-13 02:08:03
Dan Hansen @ohaibbq

Use the typeof operator to check if a variable has been declared. (typeof Var === "undefined") rather than (!Var) #jsEdu

2010-10-13 02:09:11
Andrew Hedges @segdeha

Use call and apply to invoke functions in the context of specific objects. #jsEdu

2010-10-13 02:21:39
Abderrahmane Tahri Jouti @atahrijouti

Fair chance using ternary instead of IF/ELSE: (Math.random()*100 > 50 ? alert("fair chance") : false ) #jsEdu

2010-10-13 02:29:33
Heather Mortensen @HLmortensen

Don't interfere with the user experience and disable the browser back button unless you have to in a form. #jsEdu

2010-10-13 02:31:07
Matt Wood @magearwhig

name your variables in a way that makes sense to somebody reading your code. #jsEdu

2010-10-13 02:32:31
sula eee man @sulaeman

null is a special value that means "no value", undefined means that the variable has not been declared #jsEdu

2010-10-13 02:36:19
@johniscool

test often. using alert('whatever here'); helps you know where in your code things are at when it fails. #jsEdu

2010-10-13 02:40:10
Sander Aarts 🏳️‍🌈🇺🇦 @jLix

Always use the var statement to declare a variable #jsEdu

2010-10-13 02:42:21
前へ 1 ・・ 4 5 ・・ 15 次へ