RE: [Future] First arguments should not be optional

Domenic Denicola <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <B4AE8F4E86E26C47AC407D49872F6F9F7EF891EB@BY2PRD0510MB354.namprd05.prod.outlook.com>
From: Jonas Sicking [[email protected]]

> On Wed, May 8, 2013 at 11:02 AM, Domenic Denicola <[email protected]> wrote:
>> Finally, I think the correct behavior is to ignore non-Callables, instead of throwing.

> Out of curiosity, why do you prefer that behavior? As an author I would feel that it's pretty hostile for an API to simply ignore what I requested, rather than letting me know through a thrown exception.

It's just more lenient, aligning better with existing JS libraries I've seen (not just promise ones). The spec evidence is pretty sparse---`Array.prototype.sort` versus `JSON.stringify` and `JSON.parse`. But in my experience most libraries will do either a `typeof x === "function"` test or a `if (x)` test before usage; none will do `if (typeof x !== "function" && typeof x !== "undefined")` test.

As a concrete example of how this is useful, consider

```js
var onFulfilled = handlers && handlers.onFulfilled;
promise.then(onFulfilled).done();
```

If `handlers` is `null` then this will break if only `undefined` is accepted; instead you must do

```js
var onFulfilled = handlers ? handlers.onFulfilled : undefined;
```

It's a pretty minor point though, all said. Allowing only `undefined` is fine too.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.