2010年7月28日 星期三

[javascript] 實現陣列 key , value .

PHP:
var foo = [];
foo['alfa'] = "first item";
foo['beta'] = "second item";

for (var key in foo) {
console.log(key);
}

JQUERY:
var a = {};
a['alfa'] = 0;
a['beta'] = 1;
$.each(a, function(key, value) {
alert(key)
});

JAVASCRIPT:
var foo = {};
foo['alfa'] = "first item";
foo['beta'] = "second item";

for (var key in foo) {
console.log(key);
}

沒有留言:

wibiya widget