Search Results

Search found 1 results on 1 pages for 'sethen maleno'.

Page 1/1 | 1 

  • Constructors and method chaining in JavaScript

    - by Sethen Maleno
    I am trying to make method chaining work in conjunction with my constructors, but I am not exactly sure how to go about it. Here is my code thus far: function Points(one, two, three) { this.one = one; this.two = two; this.three = three; } Points.prototype = { add: function() { return this.result = this.one + this.two + this.three; }, multiply: function() { return this.result * 30; } } var some = new Points(1, 1, 1); console.log(some.add().multiply()); I am trying to call the multiply method on the return value of the add method. I know there is something obvious that I am not doing, but I am just not sure what it is. Any thoughts?

    Read the article

1