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

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -