nodejs array cotains key code example
Example 1: javascript hashtable contains key
if (obj.hasOwnProperty("key1")) {
...
}
Example 2: javascript includes
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// output: true
if (obj.hasOwnProperty("key1")) {
...
}
const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// output: true