Making all the keys value in an array of objects blank
How to make all the key's value in an object replace with blank values...
var array = [{key1:'value',key2:'value2'},{'key1:'value',key2:'value2}]
for (item in arrayO开发者_Go百科bj) {
arrayObj[item] = ' ';
}
Is the above code right...
for (var i = 0; i< array.length; i++)
for (var item in array[i]) {
array[i][item] = ' ';
}
var array = [{key1:'value',key2:'value2'},{key1:'value',key2:'value2'}]
for(var i = 0, size = array.length; i < size; i++){
for(var key in array[i]){
array[i][key] = ' ';
}
}
for(var i=0;i<array.length;i++){
document.write("<b>array["+i+"] is </b>=>"+array[i]+"<br>");
}
That's probably the best answer for this question =D
精彩评论