Passing undefined to a JavaScript promise

Consider this simple snippet:

  .resolve('JavaScript, why are you doing this to me?')

Note that console.logg is undefined. What will be printed?


The promise will silently resolve to the value of

'JavaScript, why are you doing this to me?'

Which is a good question. I think it's because it hates me.

It's obviously a developer's mistake. My first thought was that introducing type system (like Flow) would solve this - and it would. But why isn't then method of a Promise just throwing a type error as soon as anything other than function is passed to it?

This leads to silent and hard to spot bugs. Unfortunately in JS community there is a strong attitude of ignoring the errors and going on as if nothing ever happened.