Skip to content

Instantly share code, notes, and snippets.

@raydot
Created November 25, 2019 21:23
Show Gist options
  • Save raydot/59973c3771a6ce0f78c49b975cc8b2c8 to your computer and use it in GitHub Desktop.
Save raydot/59973c3771a6ce0f78c49b975cc8b2c8 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/lenikul
<!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>
// 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