0

In babeljs v6.5.1,

class Foo {}

compiles to

"use strict";

var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Foo = function Foo() {
  (0, _classCallCheck3.default)(this, Foo);
};

What's the point of the 0 in (0, _classCallCheck3.default)(this, Foo);?

In the online babeljs repl, which probably has a different babeljs version, that line is simply _classCallCheck(this, Foo);, and they seem to do the same thing. What's the difference between these two statements?

user886596
  • 2,380
  • 5
  • 31
  • 53
  • Is "argument" the right term for me to use in the title? I have a feeling it's not, but I don't know what the correct term would be. – user886596 Feb 22 '16 at 23:40

1 Answers1

3

The 0 is ignored. It is there solely to allow the comma operator to evaluate _classCallCheck3.default and get the function without this being _classCallCheck3.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335