Skip to content

Instantly share code, notes, and snippets.

@kishanio
Last active May 2, 2017 08:09
Show Gist options
  • Save kishanio/b5489b12c7043cc277ef0be341977e67 to your computer and use it in GitHub Desktop.
Save kishanio/b5489b12c7043cc277ef0be341977e67 to your computer and use it in GitHub Desktop.
Redux : Pure vs Impure Function
// Pure Function
function square(x) {
return x * x;
}
function squareAll(items) {
return items.map(square);
}
// Impure Function
function squareAllImpure(items){
for (let i = 0; i < items.length; i++) {
items[i] = square(items[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment