相关疑难解决方法(0)

function F(){if(!(this instanceof F)){return new F()}; ...}

什么是构建的用法:function F() { if (!(this instanceof F)) { return new F() }; ... }

我在一个pty.jsfor Node中找到了这个.这是原始代码:

function Terminal(file, args, opt) {
  if (!(this instanceof Terminal)) {
     return new Terminal(file, args, opt);
  }

  var self = this
     , env
     , cwd
     , name
     , cols
     , rows
     , term;
-------------------SKIP-----------------------------------
  Terminal.total++;
  this.socket.on('close', function() {
     Terminal.total--;
     self._close();
     self.emit('exit', null);
  });

  env = null;
}
Run Code Online (Sandbox Code Playgroud)

javascript

36
推荐指数
3
解决办法
4768
查看次数

标签 统计

javascript ×1