Skip to content

Instantly share code, notes, and snippets.

@andrescabana86
Created April 8, 2017 00:11
Show Gist options
  • Save andrescabana86/802502e2efefa90af4ad56a5be438ee4 to your computer and use it in GitHub Desktop.
Save andrescabana86/802502e2efefa90af4ad56a5be438ee4 to your computer and use it in GitHub Desktop.
Pure functions examples
/*
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