1

I'm new to most of what is to follow - so I'm pretty sure I'm missing something fundamental.

This is causing me a lot of debugging-grief but for some reason strict mode is not enforced inside promise call back methods:

"use strict";
const Q = require("q");
Q(3).then(function(x){console.log(abc);})
setTimeout(function(){console.log("done!")}, 5000);

All I get on the console is after 5 seconds is done!

Now if I had done:

"use strict";    
console.log(abc);

I would get ReferenceError: abc is not defined

What's going on? How come strict-mode is not respected?


Update as soon as I posted I figured it out (new to promises).

I had not catch block. So this works as expected

Q(3)
    .then(function(x){log.info(abc);})
    .catch(function(x){log.error(x);});`
hba
  • 7,406
  • 10
  • 63
  • 105

0 Answers0