Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check property exists

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

let result = 'firstName' in person; 
console.log(result); // true

result = 'age' in person;
console.log(result); // false
Code language: JavaScript (javascript)
Source by www.javascripttutorial.net #
 
PREVIOUS NEXT
Tagged: #check #property #exists
ADD COMMENT
Topic
Name
3+4 =