Judging by the code from the question, the AddUser function will add the usual object to the usersData array and its properties will be accessed via the index of the specific object in the array + the name of the property, and you can change the same name from the console like this:
usersData[0]['name'] = 'new user name at element 0';
or so:
usersData[0].name = 'new user name at element 0';
if you need to change the name in all objects of the array elements:
function editAll(paramName, paramValue){ for (var j = 0; j < usersData.length; j++) { usersData[j][paramName] = paramValue; }; };
I didn’t immediately notice that it’s not necessary to edit everything, but the necessary element, for this you need to come up with a condition by which the necessary element will be determined, for example, editing elements with an even id :
"use strict"; var i = 0; var usersData = []; for (var k = 0 ; k < 10; k++){ AddUser('name ' + k , 'email ' + k); }; var oldArray = usersData; console.log(oldArray); editAll('name' , 'new name', function(val){ if(val == 0) return false; return !(val % 2); }); console.log(usersData); function AddUser(name, email) { usersData.push({ name: name, email: email, id: i++ }); }; function editAll(paramName, paramValue, f){ for (var j = 0; j < usersData.length ; j++) { if(f(usersData[j].id)) { usersData[j][paramName] = paramValue; }; }; };
In this example, as the determinant of the element that needs to be edited, I used the function, but you can also insert a condition directly into editAll with a check of the same id.