本文介绍了零作为IIFE中的第一个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

babeljs v6.5.1中,

class Foo {}

编译为

"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);
};

(0, _classCallCheck3.default)(this, Foo);0的意义是什么?

在在线 babeljs repl ,它可能具有不同的babeljs版本,该行就是_classCallCheck(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?

推荐答案

0被忽略.仅允许逗号运算符对_classCallCheck3.default求值并获得函数而无需this_classCallCheck3.

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.

这篇关于零作为IIFE中的第一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:50
查看更多