How to get the name of an object in an associative array (javascript) -
lets suppose have object
var clicorp14={ "id":13, "url":"corp_longboard.html", "logo":"img/corp/logolongboard.png", "alt":"longboard store", "name":"longboard", };
i want put text "alt" in var. don't want put "longboard store", want put text "alt". how access object?
object.keys(clicorp14); // -> ["id", "url", "logo", "alt", "name"]
note object.keys()
es5+ method, , available in ie9+ (although easy polyfill).
Comments
Post a Comment