Answers for "check if somethin exist in an object js"

2

how to check if object exists in javascript

if (typeof maybeObject != "undefined") {
   alert("GOT THERE");
}
Posted by: Guest on May-14-2020
1

check if somethin exist in an object js

let result = targetObject.hasOwnProperty(propertyName);

let person = {
   firstName: 'John',
   lastName: 'Doe'
};

//Example 1
let result = person.hasOwnProperty('firstName');
console.log(result); // true


//Example 2
let result = person.hasOwnProperty('age');
console.log(result); // false
Posted by: Guest on March-24-2022
0

check if somethin exist in an object js

let result = person.hasOwnProperty('firstName');
console.log(result); // true
Code language: JavaScript (javascript)
Posted by: Guest on January-18-2022

Code answers related to "check if somethin exist in an object js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language