Created
September 10, 2016 17:14
-
-
Save dengjonathan/36abfbb3e261ee1e082d8f2b8528d4f6 to your computer and use it in GitHub Desktop.
shows difference between a pure function and not pure
This file contains 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
// this is better | |
function plusOne(number) { | |
return number++; | |
} | |
plusOne(5); // 6 | |
// this is worse | |
var number = 5; | |
function plusOne() { | |
return number++; | |
} | |
plusOne(); // 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment