user1082754
user1082754

Reputation:

Promises in JavaScript — Browser and Node.js

I'm slightly confused by promises. WHATWG have a spec for DOM Promises, but I am guessing that this is just for the browser JavaScript guys to implement. Are Node considering adding similar, or will it always be the responsibility of a library such as Q? Will they ever be "native", a part of V8 and other JavaScript Engines?

Given this information, is it a good idea to use a promise library such as Q in Node code authored today? Is it future proof?

Upvotes: 1

Views: 364

Answers (1)

ssafejava
ssafejava

Reputation: 909

The same question could be asked for any browser-based code, about many of the other community shims that wrapped missing functionality in JS.

The simple answer is: ECMAScript has a long history of backwards-compatibility. Code that works today will continue to work tomorrow. Just like native Array.prototype.forEach reduced the need for shims like _.each and $.each, native Promises will give JS authors a way to use Promises without importing a library. But that's as far as it goes.

Don't wait for the spec to catch up, there are plenty of solid Promises implementations out there that work just fine.

Upvotes: 3

Related Questions