Lets suppose I have this object
var cliCorp14={
"id":13,
"url":"corp_longboard.html",
"logo":"img/corp/logoLongboard.png",
"alt":"Longboard store",
"name":"LONGBOARD",
};
I want to put the text "alt" in a var. I don't want to put "Longboard store", I want to put the text "alt". How do I access to that object?
for(var x in cliCorp14)
{
console.log(x);
}
Object.keys(cliCorp14);
// -> ["id", "url", "logo", "alt", "name"]
Note that Object.keys()
is an ES5+ method, and only available in IE9+ (although it is easy to polyfill).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.