Created
April 8, 2017 00:11
-
-
Save andrescabana86/802502e2efefa90af4ad56a5be438ee4 to your computer and use it in GitHub Desktop.
Pure functions examples
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
/* | |
pure functions are those that: | |
- are syncronous | |
- same input returns same output | |
- do not have collateral damage (change values from different scopes) | |
*/ | |
//Examples of pure functions | |
function (a, b) { | |
return a + b; | |
} | |
function changeProp(obj) { //ES6 only | |
return { | |
...obj, | |
name: 'Different name' | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment