http://stackoverflow.com/questions/5...ociative-array
la + facile
con prototypeCodice PHP:
var element_count = 0;
for(var e in car) {
if(car.hasOwnProperty(e)){
element_count++;
}
}
alert(element_count);
Codice PHP:
Object.prototype.size = function () {
var len= 0;
for(var e in this) {
if(this.hasOwnProperty(e)){
len++;
}
}
return len;
}
alert(car.size());
PS
Benvenuto nel forum
e ricordati che gli array associativi in js
sono oggetti