阅读背景:

理解对象的原型函数的'this'关键字

来源:互联网 
var Controller = function () {

try {
    throw new this.userException('test', 'test');
  } catch (error) {
    if (error instanceof this.userException) {
      console.error(error.stack);
    }
  }
}


Controller.prototype.userException = function (name, message, htmlMessage) {
  this.name = name;
  this.message = message;
  this.htmlMessage = htmlMessage;
  Error.captureStackTrace(this, this.userException);
  this.toString = function () {
    return name + ' : ' + message;
  }
};
var Controller = function () {

try {
    throw



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: