Answers for "if object contains"

0

javascript object includes

const person = {
  first_name: "Sam",
  last_name: "Bradley"
};

Object.values(person).includes("Bradley");
Posted by: Guest on May-15-2021
1

check if object has method javascript

if(typeof myObj.prop2 === 'function') {
    alert("It's a function");
} else if (typeof myObj.prop2 === 'undefined') {
    alert("It's undefined");
} else {
    alert("It's neither undefined nor a function. It's a " + typeof myObj.prop2);
}
Posted by: Guest on June-25-2020

Code answers related to "if object contains"

Code answers related to "Javascript"

Browse Popular Code Answers by Language