Skip to content

Commit

Permalink
Added one more example to [9.3](this to help with method chaining.)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince-GH committed Apr 17, 2024
1 parent c25bce8 commit 5f6bc51
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ Other Style Guides
- [9.3](#constructors--chaining) Methods can return `this` to help with method chaining.

```javascript
example:a
// bad
Jedi.prototype.jump = function () {
this.jumping = true;
Expand Down Expand Up @@ -1196,6 +1197,26 @@ Other Style Guides

luke.jump()
.setHeight(20);

example:b
//good
function Bill(UserName,Cost){
this.UserName=UserName;
this.Cost=Cost;
}

Bill.prototype.gst=function(tile){
return (tile/100)*this.Cost;
}

Bill.prototype.totalCost = function(tile){
return this.gst(tile)+this.Cost;
}

const Shanjay =new Bill("Prince",555);
console.log(Prince.Cost); //555
console.log(Prince.gst(20)); //111
console.log(Prince.totalCost(20)); //666
```

<a name="constructors--tostring"></a><a name="9.4"></a>
Expand Down Expand Up @@ -1302,6 +1323,7 @@ Other Style Guides
}
```


**[⬆ back to top](#table-of-contents)**

## Modules
Expand Down

0 comments on commit 5f6bc51

Please sign in to comment.