Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active January 19, 2018 10:12
Show Gist options
  • Save kevinchisholm/9989b2e3662d1f9b1acc5c36ee8a6e2a to your computer and use it in GitHub Desktop.
Save kevinchisholm/9989b2e3662d1f9b1acc5c36ee8a6e2a to your computer and use it in GitHub Desktop.
Code Examples for Blog Post Using fat arrow functions in your Node module
//create a tools object
var tools = {
message: 'Hello from this.message!',
asyncTask: function () {
//simulate an asynchronous task
setTimeout( function () {
console.log('THE MESSAGE IS: ' + this.message);
}, 1000);
}
};
//call asyncTask
tools.asyncTask();
//create a tools object
var tools = {
message: 'Hello from this.message!',
asyncTask: function () {
//simulate an asynchronous task
setTimeout( () => {
console.log('THE MESSAGE IS: ' + this.message);
}, 1000);
}
};
//call asyncTask
tools.asyncTask();
someFunction( message => {
console.log('THE MESSAGE IS: ' + message);
});
someFunction( (message1, message2) => {
console.log('THE MESSAGE IS: ' + message1 + ' and ' + message2);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment