Answers for "Testing Objects for Properties"

0

Testing Objects for Properties

function checkObj(obj, checkProp) {
  if(obj.hasOwnProperty(checkProp)){
    return obj[checkProp];
  }else{
    return "Not Found"
  }
}
Posted by: Guest on December-17-2020
0

testing objects for properties javascript

var myObj = {
  top: "hat",
  bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle"); // false
Posted by: Guest on July-19-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language