This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var func = ( x, y ) => x + y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var func = ( x, y ) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var func = ( x, y ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var square = number => number * number; | |
console.log( square( 5 ) ); // 25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Gamer() { | |
// 'this' refers to Gamer | |
this.playTime = 0; | |
// We use an ES6 arrow function | |
setInterval(() => { | |
// So 'this' still refers to the Gamer object | |
this.playTime++; | |
// Correctly outputs and incremented value representing play time in seconds | |
console.log( this.playTime ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Gamer() { | |
// Store value of this in a variable | |
var self = this; // Some people use that or _this | |
self.playTime = 0; | |
// trackPlayTime() will now correctly auto increment every second | |
setInterval( function trackPlayTime() { | |
// Because we're using a variable we don't have to worry about the dynamic value of this in the new function scope | |
self.playTime++; | |
// Correctly out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Gamer() { | |
// 'this' refers to Gamer | |
this.playTime = 0; | |
// We think trackPlayTime() will update a gamer's playtime every second | |
setInterval( function trackPlayTime() { | |
// But we're wrong because trackPlayTime() creates it's own version of 'this' | |
this.playTime++; | |
// Outputs NaN, because this.playTime was never cast as an integer in this scope | |
console.log( this.playTime ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Multiple statements | |
([param] [,param]) => { | |
statements | |
} | |
// Single expression | |
param => expression | |
/* _____ Examples _____ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ignore osx,windows,linux,sublimetext,eclipse,node,grunt,bower,sass,jetbrains > .gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ignore list |