为了账号安全,请及时绑定邮箱和手机立即绑定

class.prototype.foo=function foo 这样写的用意是什么

class.prototype.foo=function foo 这样写的用意是什么

SMILET 2018-08-08 13:13:27
在nodejs的源码中看到这样的写法class.prototype.foo=function foo,想问问这样的的用意是什么?EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {  if (typeof n !== 'number' || n < 0 || isNaN(n))    throw new TypeError('n must be a positive number');  this._maxListeners = n;  return this;};我的问题是问什么还要在function后面再声明一次函数名// 为什么不这样写,而要在多声明一次EventEmitter.prototype.setMaxListeners = function (n) {  if (typeof n !== 'number' || n < 0 || isNaN(n))    throw new TypeError('n must be a positive number');  this._maxListeners = n;  return this;};
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 613 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号