Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check property exists in object javascript

const employee = {
	id: 1,
  	name: "Jhon",
  	salary: 5000
};

const isSalaryExist = "salary" in employee;
console.log(isSalaryExist); //true

const isGenderExist = "gender" in employee;
console.log(isGenderExist); //false
Source by h.daily-dev-tips.com #
 
PREVIOUS NEXT
Tagged: #check #property #exists #object #javascript
ADD COMMENT
Topic
Name
9+4 =