# o-has

> Returns true if an object has a given property

Latest version **1.0.0** (published 2016-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install o-has
pnpm add o-has
yarn add o-has
bun add o-has
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-15 |
| First published | 2016-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vikram Jadhav |
| Maintainers | vikramcse |
| Keywords | has, property, object, check, key, exists |

## Links

- npm: https://www.npmjs.com/package/o-has
- Repository: https://github.com/vikramcse/o-has
- Homepage: https://github.com/vikramcse/o-has#readme
- Issues: https://github.com/vikramcse/o-has/issues
- npm.io page: https://npm.io/package/o-has

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-03-15

## README

# o-has
Returns true if an object has a given property

## Install

```sh
$ npm install --save o-has
```

## Example

```js
var has = require('o-has');

var a = {
  name: 'vikram'
};

console.log(has(a, 'name'));
// -> true
```

### Explination

In case we are using JavaScript objects for hashtable sulution then, 
we can rely on any of its inherited properties such as **hasOwnProperty**
here is an example

```js
var obj = {
	name: 'vikram',
	hasOwnProperty: 'dummy'
};

console.log(obj.hasOwnProperty('hasOwnProperty'));
// -> TypeError: Property 'hasOwnProperty' of object obj is not a function
```

In above example it tries to execute *inherited* hasOwnProperty and which
not a function.

The workaround for this problem is to use *Object.prototype* hasOwnProperty method


### `require('o-has')(object, key)`

**Arguments**:
- `object`: Object
- `key`: the key that to be checked

**Returns**: Returns true if an object has a given property

## License

&copy; 2016 vikram. MIT License

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