How to add a property in JavaScript object? -


this question has answer here:

i have javascript object:

var credentials =  {      uid: response.authresponse.userid,      accesstoken: response.authresponse.accesstoken  }; 

how can add in object name: response.something?

javascript objects dynamic. means can add property object @ time doing this:

credentials.name = response.something; 

or equivalently:

credentials['name'] = response.something; 

ecmascript 5 only:

object.defineproperty( credentials, "name", {     value: response.something,     writable: true,     enumerable: true,     configurable: true }); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -