Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
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
Lodash's 'has' function is similar to 'has' in that it checks if a path is a direct property of an object. However, lodash.has also allows checking for deep properties using a dot or array path notation, which 'has' does not support.
This package provides functionality similar to 'has' by checking if an object contains a certain property. The difference is mainly in the implementation and the specific API provided by the package.
Object.prototype.hasOwnProperty.call shortcut
npm install --save has
var has = require('has');
has({}, 'hasOwnProperty'); // false
has(Object.prototype, 'hasOwnProperty'); // true
FAQs
Object.prototype.hasOwnProperty.call shortcut
The npm package has receives a total of 11,966,642 weekly downloads. As such, has popularity was classified as popular.
We found that has demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.