# JS Tip of the Day: Thenable Objects

**URL:** https://forum.kirupa.com/t/js-tip-of-the-day-thenable-objects/643177
**Category:** web dev
**Created:** [February 19, 2020, 5:35pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-thenable-objects/643177 "2020-02-19T17:35:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [February 19, 2020, 5:35pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-thenable-objects/643177/1 "2020-02-19T17:35:02Z")

</div>

**Thenable Objects**  
Version: ES2015  
Level: Advanced

A thenable is any object that has a function property named `then`. The following is an example of a thenable object:

```javascript
let myThenable = { then () {} };

```

Thenable objects in JavaScript are objects that are given special treatment when resolved by promises, effectively being seen as promise objects themselves. Rather than a thenable object becoming the resolved value, the `then()` method of the object is called and passed `resolve` and `reject` functions, much like you would specify in a `then` called from a promise. The thenable can then provide the promise chain a resolved or rejected value using these functions.

```auto
let normalObject = { normal: true };
let thenableObject = {
    then (resolve, reject) {
        resolve(1);
    }
};

Promise.resolve(normalObject)
    .then(value => console.log(value)); // { normal: true }

Promise.resolve(thenableObject)
    .then(value => console.log(value)); // 1

```

Thenables make it easy for built-in promises to work with alternative promise implementations as long as they use thenable objects.

More info:

- [Promise.resolve() on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)
