Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add arrow function in ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed May 13, 2016
1 parent 18cad51 commit 0ea87bf
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions es6/arrow_function.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ var betterGreeting = (message, name) => message + name;

var squared = x => x * x;

var delieverBoy = {
name: "John",
// Original
var deliveryBoy = {
name: "Anthony",

handleMessage: function (message, handler) {
handler(message);
Expand All @@ -27,3 +28,18 @@ var delieverBoy = {
})
}
}

// Arrow Function
var delivery = {
name: "Anthony",

handleMessage: function (message, handler) {
handler(message);
},

receive: function () {
this.handleMessage("Hello, ", messages => console.log(message + this.name))
}
}

deliverBoy.receive();

1 comment on commit 0ea87bf

@sicktastic
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way cleaner 👍

Please sign in to comment.