Javascript node.js中的继承问题:尝试覆盖子类的原型时发生分配错误

Javascript node.js中的继承问题:尝试覆盖子类的原型时发生分配错误,javascript,node.js,inheritance,Javascript,Node.js,Inheritance,谢谢你抽出时间来帮助我。我试图学习node.js,在理解继承时遇到了以下问题: var stream = require('stream'); var util = require('util'); util.inherits(Answers, stream.Readable); function Answers(opt) { stream.Readable.call(this, opt); this.quotes = ["yes", "negatory", "possibl

谢谢你抽出时间来帮助我。我试图学习node.js,在理解继承时遇到了以下问题:

var stream = require('stream');
var util = require('util');

util.inherits(Answers, stream.Readable);

function Answers(opt) {
    stream.Readable.call(this, opt);
    this.quotes = ["yes", "negatory", "possibly"];
    this._index = 0;
}

Answers.prototype._read() = function() {
    if (this._index > this.quotes.length) {
        this.push(null);
    }
    else {
        this.push(this.quotes[this._index]);
        this._index += 1;
    }
};
我的错误表明我有一个无效的左侧赋值,我试图覆盖stream.Readable的原型(第12行)。我想是打电话给

util.inherits(Answers, stream.Readable);

允许我忽略stream.Readable的_read()函数。任何帮助都将不胜感激。提前谢谢

答案。原型。_read()
。。。您正在为函数调用赋值。只需将其更改为
Answers.prototype.\u read=function()…
Answers.prototype.\u read()
。。。您正在为函数调用赋值。只需将其更改为
Answers.prototype.\u read=function()…
Answers.prototype.\u read()
。。。您正在为函数调用赋值。只需将其更改为
Answers.prototype.\u read=function()…
Answers.prototype.\u read()
。。。您正在为函数调用赋值。只需将其更改为
Answers.prototype.\u read=function()…

没有行号,即“第12行”?没有行号,即“第12行”?没有行号,即“第12行”?没有行号,即“第12行”?哇,感谢您的快速回答!啊,真不敢相信我错过了,但至少我知道我不会再犯那个错误了,并且在这个过程中得到了一个关于继承的好教训。哇,谢谢你这么快的回答!啊,真不敢相信我错过了,但至少我知道我不会再犯那个错误了,并且在这个过程中得到了一个关于继承的好教训。哇,谢谢你这么快的回答!啊,真不敢相信我错过了,但至少我知道我不会再犯那个错误了,并且在这个过程中得到了一个关于继承的好教训。哇,谢谢你这么快的回答!呃,真不敢相信我错过了,但至少我知道我不会再犯那个错误,并在这个过程中得到了关于继承的好教训。