I have the following:
new Promise(resolve => setTimeout(resolve, 2000))
    .then(() => console.log("after 2 seconds"));
new Promise(resolve => setTimeout(resolve, 3000))
    .then(console.log("before 3 seconds (instantly)"));
which produces the following output:
> node index.js
before 3 seconds (instantly)
after 2 seconds
Promise.then() expects a onFulfilled function, but I passed in console.log("before 2 seconds (instantly)"), which is not a function. Two-part question:
- Why does console.log("before 2 seconds (instantly)")get executed right away (or at all)?
- Why didn't the second Promise raise an exception when I didn't pass in a function?
 
     
     
    