# Check if an object is a Promise

Detect a thenable: an object or function with a then method.

Canonical: https://1loc.dev/validator/check-if-an-object-is-a-promise/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Usage lines executed in Node.js 22 and headless Chromium; no external services
Updated: 2026-10-28

## Implementation

```javascript
function isPromise(value) { return value !== null && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function'; }
```

## Usage

```javascript
isPromise(Promise.resolve('sent')); // → true
isPromise({ then() {} }); // → true
isPromise(async () => {}); // → false
isPromise(null); // → false
```

Lines marked → were executed in Node.js 22 and in headless Chromium, and each result was compared with the value shown. Lines marked e.g. are illustrative.

## Limits

- This detects thenables, which is what await and Promise.resolve accept; a plain object with then counts, as the second line shows.
- To normalize instead of testing, write await value or Promise.resolve(value).

The function does not validate its arguments. Add checks where it receives untrusted input.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/check-if-an-object-is-a-promise.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: quantumsheep
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Documented as a reference with executed usage lines. Original MDX retained as inert source evidence.
