I can create a Json object as here
How to create json by javascript for loop?
great!
and I have created one like below
[
{
"id": "10",
"userName": "kuttan"
},
{
"id": "11",
"userName": "kunjan"
}
]
Suppose I want to update name of the user with id 10 to “new name”
what should i do?(i dont know the index is 1)
Loop over your array of objects (because that’s what it is), and check the “id” attribute of each object.
You could then abstract this into some nice function.
Then use it as follows: