我在這裏做錯了什麼?我的數組是空的。Javascript推送方法
var infoarray = [{"address":"07288 Albertha Station","city":"Littelside","created_at":"2011-05-25T19:24:51Z","id":1,"name":"Mr. Emmitt Emmerich","state":"Missouri","updated_at":"2011-05-25T19:24:51Z","zip":"75475-9938"},{MORE INFO}]
// Populates myarray from infoarray ruby object
var myarray = new Array();
$(document).ready(function(){
$.each(infoarray,function(key,value){
myarray.push(value['city'])
});
});
console.log(myarray);
適用於我:http://jsfiddle.net/uqzjQ/ – mVChr 2011-05-26 21:16:15