array includes key javascript code example
Example 1: how to check if a key exists in an object javascript
!("key" in obj)
!"key" in obj
Example 2: array includes
let storyWords = ['extremely', 'literally', 'actually', 'hi', 'bye', 'okay']
let unnecessaryWords = ['extremely', 'literally', 'actually' ];
let betterWords = storyWords.filter(function(word) {
return !unnecessaryWords.includes(word);
});
console.log(betterWords)
Example 3: js check if object key exists
var obj = { key: undefined };
obj["key"] !== undefined