Socket
Socket
Sign inDemoInstall

has

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

has

Object.prototype.hasOwnProperty.call shortcut

    1.0.4latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
22,240,627
decreased by-15.83%

Weekly downloads

Package description

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.

What are has's main functionalities?

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

Other packages similar to has

Readme

Source

has

Object.prototype.hasOwnProperty.call shortcut

Installation

npm install --save has

Usage

var has = require('has');

has({}, 'hasOwnProperty'); // false
has(Object.prototype, 'hasOwnProperty'); // true

FAQs

Last updated on 03 Oct 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc