testing objects for properties javascript

Solutions on MaxInterview for testing objects for properties javascript by the best coders in the world

showing results for - "testing objects for properties javascript"
Nicola
27 Jan 2019
1function checkObj(obj, checkProp) {
2  if(obj.hasOwnProperty(checkProp)){
3    return obj[checkProp];
4  }else{
5    return "Not Found"
6  }
7}
Josefa
02 Mar 2018
1var myObj = {
2  top: "hat",
3  bottom: "pants"
4};
5myObj.hasOwnProperty("top");    // true
6myObj.hasOwnProperty("middle"); // false
similar questions
queries leading to this page
testing objects for properties javascript