方法链接返回未定义

method chaining returning undefined

我有以下javascriptclass

var a = function () {
    this.data = {};
};

a.prototype.parseString = function (string) {
    this.data = string.split(',');
}

a.prototype.performOperationB = function () {
    this.iPo = _.map(this.data, function () {
        if (item.indexOf('ip') > -1) {
            return item;
        }
    });
}

a.prototype.save = function (string) {
    this.parseString(string)
        .performOperationB()
        // some other chained methods
}
var b = new a();

b.save(string);

会returnTypeError: Cannot read property 'performOperationB' of undefined

是否可以在另一种方法中一个接一个地链接原型方法?

Return this 来自

a.prototype.parseString = function(string) {
   this.data  = string.split(',');
   return this;
}

因为现在方法returnsundefined

var a = function () {
  this.data = {};
};

a.prototype.parseString = function (string) {
  this.data = string.split(',');
  return this;
}

a.prototype.performOperationB = function () {
  this.iPo = _.map(this.data, function (item) {
    if (item.indexOf('ip') > -1) {
      return item;
    }
  });
}

a.prototype.save = function (string) {
  this.parseString(string)
     .performOperationB()
}
var b = new a();

b.save('string');
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>