What is has?
The 'has' npm package is a utility module that provides a function to check if an object has a property with a given key. It is a safer way to check for properties than the built-in JavaScript 'in' operator or property access, as it doesn't check the prototype chain and avoids potential issues with objects that have modified prototypes or lack a prototype altogether.
Check for own property
This feature allows you to check if an object has a specific own property. It returns true if the property exists directly on the object, and false otherwise.
const has = require('has');
const obj = { a: 1 };
console.log(has(obj, 'a')); // true
console.log(has(obj, 'b')); // false