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"> | |
<title>MDN Games: A-Frame demo</title> | |
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script> | |
</head> | |
<body> | |
<a-scene> <!--The a scene is responsible for rendering the objects nested within it--> | |
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <!--The a-sphere is a sphere we are creating with some css like inline declaration--> |
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
function foo(x) { | |
var a = 5, | |
test = 6, | |
a = function test() { console.log('hello foo'); } | |
a(); | |
test(); | |
function test() { console.log('hello test'); } | |
} |
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
/* Global Context */ | |
var addNum = function sum(x,y) { | |
console.log(x+y); | |
} | |
function minusNum(x,y) { | |
console.log(x-y); | |
} | |
addNum(2,3) // 5 | |
minusNum(2,3) // -1 |
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
VariableObject : { | |
/* no argument for the global context */ | |
minusNum: pointer to function minusNum, | |
addNum: undefined | |
} |
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
VariableObject : { | |
/* no argument for the global context */ | |
minusNum: pointer to function minusNum, | |
addNum: pointer to function sum | |
} |
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
VariableObject: { | |
x: 2, //these are arguments | |
y: 3 // | |
} |
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
// First calculate the total cost of the pizza including tax | |
const calcTotalWithTax = pizzaCost => pizzaCost * 1.13 // Here in Toronto, tax is 13% | |
// Then calculate the cost of pizza for two people | |
const costForTwo = itemCost => Math.round(itemCost/2 * 100) / 100 | |
// implement pipe function | |
// the pipe function accepts only two | |
// operations | |
const pipe = (op1, op2) => { |
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
const pipe = (op1, op2) => { | |
return (arg) => { | |
const result1 = op1(arg); | |
return op2(result1); | |
} | |
} |
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
const pipe = (op1, op2) => (arg) => op2(op1(arg)); |
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
// Utilize the previous pipe function that accepts only two functions | |
const _pipe = (a, b) => (arg) => b(a(arg)); | |
// The rest parameters creates an array of operations | |
const pipe = (...ops) => { | |
// Iterate over the array of operations | |
// By using reduce, merge all operations into a single bundle | |
let bundle = ops.reduce((prevOp, nextOp) => { | |
return _pipe(prevOp,nextOp); |
OlderNewer