Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check many keys in objects

const neededKeys = ['oldPassword', 'name', 'newPassword'];

const obj = {
    "name": "admin@test.org",
    "oldPassword": "1234",
    "newPassword": "12345"
}

console.log(neededKeys.every(key => Object.keys(obj).includes(key)));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #keys #objects
ADD COMMENT
Topic
Name
2+1 =