# just-safe-get

> get value at property, don't throw if parent is undefined

Latest version **4.2.0** (published 2022-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install just-safe-get
pnpm add just-safe-get
yarn add just-safe-get
bun add just-safe-get
```

## 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 | 4.2.0 |
| Published | 2022-12-17 |
| First published | 2016-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6201 |
| Author | Angus Croll |
| Maintainers | angus-c |
| Keywords | object, safe, get, no-dependencies, just |

## Links

- npm: https://www.npmjs.com/package/just-safe-get
- Repository: https://github.com/angus-c/just
- Homepage: https://github.com/angus-c/just#readme
- Issues: https://github.com/angus-c/just/issues
- npm.io page: https://npm.io/package/just-safe-get

## Recent versions

- 4.2.0 (latest) — 2022-12-17
- 4.1.1 — 2022-08-08
- 4.1.0 — 2022-08-07
- 4.0.1 — 2021-11-13
- 4.0.0 — 2021-11-09
- 3.1.1 — 2021-11-01
- 3.1.0 — 2021-10-31
- 3.0.0 — 2021-10-22
- 2.1.2 — 2021-05-08
- 2.1.1 — 2021-04-04
- 2.1.0 — 2021-04-04
- 2.0.0 — 2019-08-22
- 1.3.3 — 2019-08-22
- 1.3.2 — 2019-08-09
- 1.3.1 — 2019-08-09
- … 5 more at https://npm.io/package/just-safe-get/versions

## README

<!-- DO NOT EDIT THIS FILE! THIS FILE WAS AUTOGENERATED BY TEMPLATE-MATE -->
<!-- SEE https://github.com/angus-c/just/blob/master/CONTRIBUTING.md#readme-template -->

## just-safe-get

Part of a [library](https://anguscroll.com/just) of zero-dependency npm modules that do just do one thing.
Guilt-free utilities for every occasion.

[`🍦 Try it`](https://anguscroll.com/just/just-safe-get)

```shell
npm install just-safe-get
```
```shell
yarn add just-safe-get
```

Get value at property, don't throw if parent is undefined

```js
import get from 'just-safe-get';

const obj = {a: {aa: {aaa: 2}}, b: 4};

get(obj, 'a.aa.aaa'); // 2
get(obj, ['a', 'aa', 'aaa']); // 2

get(obj, 'b.bb.bbb'); // undefined
get(obj, ['b', 'bb', 'bbb']); // undefined

get(obj.a, 'aa.aaa'); // 2
get(obj.a, ['aa', 'aaa']); // 2

get(obj.b, 'bb.bbb'); // undefined
get(obj.b, ['bb', 'bbb']); // undefined

get(obj.b, 'bb.bbb', 5); // 5
get(obj.b, ['bb', 'bbb'], true); // true

get(null, 'a'); // undefined
get(undefined, ['a']); // undefined

get(null, 'a', 42); // 42
get(undefined, ['a'], 42); // 42

const obj = {a: {}};
const sym = Symbol();
obj.a[sym] = 4;
get(obj.a, sym); // 4
```

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