# getown

> Lookup an object property only if it's its own property.

Latest version **1.0.2** (published 2026-04-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install getown
pnpm add getown
yarn add getown
bun add getown
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-04-12 |
| First published | 2019-04-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=24.0.0 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M.K. |
| Maintainers | mk-pmb |

## Links

- npm: https://www.npmjs.com/package/getown
- Repository: https://github.com/mk-pmb/getown-js
- Homepage: https://github.com/mk-pmb/getown-js/#readme
- Issues: https://github.com/mk-pmb/getown-js/issues
- npm.io page: https://npm.io/package/getown

## Recent versions

- 1.0.2 (latest) — 2026-04-12
- 1.0.1 — 2025-01-04
- 1.0.0 — 2020-06-27
- 0.1.0 — 2019-04-21

## README

<!--#echo json="package.json" key="name" underline="=" -->
getown
======
<!--/#echo -->

<!--#echo json="package.json" key="description" -->
Lookup an object property only if it&#39;s its own property.
<!--/#echo -->



API
---

This module exports one function that holds a method:

### getown(obj, prop, fallback)

Returns `obj[prop]` if `obj` is truthy and has an own property `prop`,
otherwise returns `fallback`.


### getown.voc(dict, word)

Alias for `getown(dict, word, word)`.
Useful to not repeat yourself.
Especially useful in case you calculate `word` on the fly and don't want
to evaluate the formula twice.




Usage
-----

from [test/usage.mjs](test/usage.mjs):

<!--#include file="test/usage.mjs" transform="mjsUsageDemo1802" -->
<!--#verbatim lncnt="16" -->
```javascript
import getown from 'getown';
const dict = { foo: 'bar' };
same(getown(dict, 'foo'), 'bar');
same(getown(dict, 'bar'), undefined);
same(getown(dict, 'bar', 321), 321);
same(typeof dict.toString, 'function');
same(getown(dict, 'toString'), undefined);

same(getown.voc(dict, 'foo'), 'bar');
same(getown.voc(dict, 'bar'), 'bar');
same(getown.voc(dict, 'qux'), 'qux');

same(getown(null, 'wow'), undefined);
same(getown(null, 'wow', 'doge'), 'doge');
```
<!--/include-->


<!--#toc stop="scan" -->



Known issues
------------

* Needs more/better tests and docs.




&nbsp;


License
-------
<!--#echo json="package.json" key=".license" -->
ISC
<!--/#echo -->

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