# has-own-prop

> A safer `.hasOwnProperty()`

Latest version **3.1.0** (published 2021-11-01) · MIT license · 0 weekly downloads

> **Native alternative:** Object.prototype.hasOwnProperty.call(obj, prop) (or in later versions of node, "Object.hasOwn(obj, prop)") — Use native JavaScript (Node 0.10.0+) (https://developer.mozilla.orgGlobal_Objects/Object/hasOwnProperty)

## Install

```sh
npm install has-own-prop
pnpm add has-own-prop
yarn add has-own-prop
bun add has-own-prop
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2021-11-01 |
| First published | 2014-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | object, has, own, property |

## Links

- npm: https://www.npmjs.com/package/has-own-prop
- Repository: https://github.com/sindresorhus/has-own-prop
- Homepage: https://github.com/sindresorhus/has-own-prop#readme
- Issues: https://github.com/sindresorhus/has-own-prop/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/has-own-prop

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 3.1.0 (latest) — 2021-11-01
- 3.0.0 — 2021-09-06
- 2.0.0 — 2019-06-12
- 1.0.1 — 2018-03-23
- 1.0.0 — 2014-08-06

## README

# has-own-prop

> A safer `.hasOwnProperty()`

Shortcut for `Object.prototype.hasOwnProperty.call(object, property)`. Also comes with a type guard for TypeScript users.

You shouldn't use `.hasOwnProperty()` as it won't exist on [objects created with `Object.create(null)`](https://stackoverflow.com/a/12017703/64949) or it can have been overridden.

## Install

```sh
npm install has-own-prop
```

## Usage

```js
import hasOwnProperty from 'has-own-prop';

const object = Object.create(null);
object.unicorn = true;

object.hasOwnProperty('unicorn');
//=> 'TypeError: undefined is not a function'

hasOwnProperty(object, 'unicorn');
//=> true
```

---
_Source: https://npm.io/package/has-own-prop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
