Created
November 25, 2019 21:23
-
-
Save raydot/59973c3771a6ce0f78c49b975cc8b2c8 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/lenikul
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://fb.me/react-with-addons-15.1.0.js"></script> | |
<script src="https://fb.me/react-dom-15.1.0.js"></script> | |
<script id="jsbin-javascript"> | |
// Pure Functions | |
"use strict"; | |
function square(x) { | |
return x * x; | |
} | |
function squareAll(items) { | |
return item.map(square); | |
} | |
// Impure functions | |
function square(x) { | |
updateXInDatabase(x); // <- IMPURE! | |
return x * x; | |
} | |
function squareAll(items) { | |
for (var i = 0; i < items.length; i++) { | |
items[i] = sqare(items[i]); // <- IMPURE! | |
} | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Pure Functions | |
function square(x) { | |
return x * x; | |
} | |
function squareAll(items) { | |
return item.map(square); | |
} | |
// Impure functions | |
function square(x) { | |
updateXInDatabase(x); // <- IMPURE! | |
return x * x; | |
} | |
function squareAll(items) { | |
for (let i = 0; i < items.length; i++) { | |
items[i] = sqare(items[i]) // <- IMPURE! | |
} | |
}</script></body> | |
</html> |
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 | |
"use strict"; | |
function square(x) { | |
return x * x; | |
} | |
function squareAll(items) { | |
return item.map(square); | |
} | |
// Impure functions | |
function square(x) { | |
updateXInDatabase(x); // <- IMPURE! | |
return x * x; | |
} | |
function squareAll(items) { | |
for (var i = 0; i < items.length; i++) { | |
items[i] = sqare(items[i]); // <- IMPURE! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment