has
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
function-bind | 1.1.2 | 9.57 kB | MIT | prod |
The "has" npm package is a handy JavaScript tool providing a shortcut to the Object.prototype.hasOwnProperty.call method. This package is widely used as a utility to check if an object possesses a specific property. The package saves developers from writing longer codes to check object properties by making the process simpler, efficient, and cleaner.
To use the "has" npm package, you first need to install it into your project by running npm install --save has
in your project terminal. Once installed, you can require it at the top of your JavaScript file where you want to use it. Here is a basic example of how to use it:
var has = require('has');
// Checking if an empty object has the 'hasOwnProperty' property
console.log(has({}, 'hasOwnProperty')); // This will output : false
// Checking if the Object.prototype has the 'hasOwnProperty' property
console.log(has(Object.prototype, 'hasOwnProperty')); // This will output : true
In this code, 'has' checks if the provided object (first parameter) has the named property (second parameter).
The official documentation of the "has" npm package can be found on its GitHub page, located at https://github.com/tarruda/has. The README provides a clear guide to installing and using the package, along with examples. Keep in mind to stay updated with any changes that can be published.