Why does Array.prototype.push return the new length instead of something more useful?

I understand the expectation for array.push() to return the mutated array instead of its new length. And the desire to use this syntax for chaining reasons. However, there is a built in way to do this: array.concat(). Note that concat expects to be given an array, not an item. So, remember to wrap the item(s) … Read more

How to wait for a JavaScript Promise to resolve before resuming function?

I’m wondering if there is any way to get a value from a Promise or wait (block/sleep) until it has resolved, similar to .NET’s IAsyncResult.WaitHandle.WaitOne(). I know JavaScript is single-threaded, but I’m hoping that doesn’t mean that a function can’t yield. The current generation of Javascript in browsers does not have a wait() or sleep() … Read more