Close

Not a member yet? Register now and get started.

lock and key

Sign in to your account.

Account Login

Forgot your password?

JS bulit-in for-in vs jQuery.each()

JS bulit-in for-in:
程式碼:

if (data.station) {
    for (var key in data.station) {
        alert('for-in: ' + data.station[key]['id'] + ': ' + data.station[key]['name']);
    }
}

vs

.each():
程式碼:

?View Code JQUERY
if (data.station) {
    $.each(data.station, function(idx, val) {
        alert('$.each: ' + val.id + ': ' + val.name);
    });
}

相關文章 Related posts:

  1. 比對條件反轉注意事項
  2. CSS樣式架構[4] 模組套件型 (Module)
  3. 避免 TinyMCE 必填檢查要送交兩次才正確的解法
  4. JavaScript 物件屬性存取技巧

Leave a Reply

*