javascript - Alter array object using loop -
var arr = [{id:1,"name":"john"},{id:2,"name":"james"}] $.each(arr, function(){ if(this.id == 1){ //change john johnathan } });
without using key, possible alter array object?
sure can converting object string if looking hack. looking do?
var arr = [{id:1,"name":"john"},{id:2,"name":"james"}] $.each(arr, function(i){ if(this.id == 1){ arr[i] = json.parse(json.stringify(this).replace("john", "johnathan")) } });
Comments
Post a Comment