Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Check object property exists or not in js

const user1 = {
	username: "john"
};
const user2 = {
	username: "duo"
    authority: "grepper"
}
// check object property
console.log(user1.hasOwnProperty('authority')); // false
console.log(user2.hasOwnProperty('authority')); // true
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Check #object #property #exists #js
ADD COMMENT
Topic
Name
3+6 =