Regist this document on your website and blog and share it with many people. It's simple.

Description : JAVASCRIPT COMMON MISTAKES
Dongsu Jang http://blog.iolo.pe.kr
Unaware of: Async! Async! Async!
var result1, result2, result3; $.ajax(..., success: function(data) { result1 = data; }); $.ajax(..., success: function(data) { result2 = data; }); result3 = result1 + result2;
But, don‟t do that: “async: false”
Unaware of: this “this” is not the “this”
function test(name, button) { this.name = name; button.onclick = function(event) { alert('hello, ' + this.name); }; }
Unaware of: “not of not” is not the not of “not”
function test(foo) { alert(typeof(foo)); alert(foo); if (foo) { alert('foo'); } if (!foo) { alert(„!foo'); } if (!!foo) { alert('!!foo'); } }
Misunderstaning 0, null, false, undefined, NaN and “”
function test(foo) { alert(typeof(foo)); alert(foo); if (foo) { alert('foo'); } if (foo == null) { alert('foo == null'); } if (foo === null) { aler
Tags: javascript
Some rights reserved. ![]()
779 views, 0 favorites
Comments ( 0 / 600 )