How to check if a JavaScript Object has a property name that starts with a specific string?

You can check it against the Object’s keys using Array.some which returns a bool.

if(Object.keys(obj).some(function(k){ return ~k.indexOf("addr") })){
   // it has addr property
}

You could also use Array.filter and check it’s length. But Array.some is more apt here.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)