javascript - assigning new value to an object in object array in jquery -


i have array of objects

object in below format

var newuserdetail={"age":"21","name":"vicky","userid":"198303"}; 

now trying compare userid , replace values

//userslist contains array of newuserdetail kind of objects  jquery(userslist).each(function(){ if(this.userid==newuserdetail.userid){ this=newuserdetail; } }); 

but throws error

invalid left-hand side in assignment 

set array entry:

jquery(userslist).each(function (i) {     if (this.userid == newuserdetail.userid) {         userslist[i] = newuserdetail;         return false; //if want break loop     } }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -