1

I'm working with some javascript generators. It has generated a line like:

(0, _myTest.testfunc)();

What is the meaning of this line?

OK - The testfunc is the a function that should be called and comes from a module loader. But what is the meaning of the first () with the comma between?

powerpete
  • 2,663
  • 2
  • 23
  • 49
  • 2
    It's a way of calling `_myTest.testfunc` but ensuring that `this` during the call *isn't* `_myTest` (it'll either be `undefined` in strict mode or a reference to the global object in loose mode). Equivalent to `var f = _myTest.testfunc; f();` but without the temporary `f` variable. See the linked question's answers for details. – T.J. Crowder Nov 27 '17 at 14:55
  • [Also this question.](https://stackoverflow.com/questions/9735424/whats-the-reason-for-using-such-syntax-0-em) – Pointy Nov 27 '17 at 14:57

0 Answers0