Check if a Javascript Object has a property name that starts with a specific string -
lets have javascript objects one:
addr:housenumber: "7" addr:street: "frauenplan" owner: "knaut, kaufmann"
how can check if object has property name starts addr
? i’d imagine along lines of following should possible:
if (e.data[addr*].length) {
i tried regexp
, .match()
no avail.
you can check against object's keys using array.some
returns bool
.
if(object.keys(obj).some(function(k){ return ~k.indexof("addr") })){ // has addr property }
you use array.filter
, check it's length. array.some
more apt here.
Comments
Post a Comment