Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created September 10, 2016 19:07
Show Gist options
  • Save dengjonathan/506325caaaf1466505efc2b5e1d417cb to your computer and use it in GitHub Desktop.
Save dengjonathan/506325caaaf1466505efc2b5e1d417cb to your computer and use it in GitHub Desktop.
pure function
var d = 'not modified';
// add is a pure function that doesn't modify anything out of its scope
function add(x, y) {
return x + y;
}
add(2, 3) // 5
add(2, 3) // always gonna be 5
console.log(d) // 'not modified'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment