How to add a property in JavaScript object? -
this question has answer here:
- javascript: expando property? 3 answers
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
Post a Comment