2

I've come across this pattern:

(0, _inherits3.default)(SpecRunner, _File);

I can't completely wrap my mind around it -- to me it looks like the comma operator is being used, which would evalute the expressions inside the first pair of parentheses from left to right and return the last expression, in this case inherits3.default. In case this is a callable, it would call it with the arguments SpecRunner and _File.

Is my analysis correct and if so, why would someone, instead of writing,

_inherits3.default(SpecRunner, _File);

use such a pattern?

  • Out of curiosity's sake, is the context available? EDIT: [yes](https://github.com/cotto89/squads/blob/dc72b58531a0e3e7613d1d137164d2061cbc2c2c/dist/helper/errors.js#L48).. I wonder, since it's the output of some transpiler.. – Nebula Oct 06 '16 at 12:52
  • 1
    That looks like something that a transpiler might emit. – Pointy Oct 06 '16 at 12:52
  • possible better dupe target: http://stackoverflow.com/questions/32275135/why-does-babel-rewrite-imported-function-call-to-0-fn – Bergi Oct 06 '16 at 12:54
  • 1
    The effect is that the value of `this` in the function will be the default value instead of the `_inherits3` object. As to why, you'd need to ask the one who wrote it. –  Oct 06 '16 at 12:55
  • @squint `undefined`, not the `.default` itself – Bergi Oct 06 '16 at 14:25
  • @Bergi: Yes, I can see how what I wrote could be confusing. I meant the default `this` value that gets assigned when there's no definite object ot use, so either `undefined` or the global object when not in strict mode. –  Oct 06 '16 at 14:26

0 Answers0