零作为IIFE中的第一个参数 [英] Zero as first argument in IIFE

查看:64
本文介绍了零作为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的意义是什么?

在在线

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中的第一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆