\n\n\nhttps://www.crockford.com/pp/functions.js\n function identity(x) {\n return x;\n }\n console.log(\"identity\", 3, identity(3));
\nslide10. The Rules If you have a question, you must ask it.\nI won’t debug your stuff.\nIf you need more time, let me know.
\nslide11. Quiz
\nslide12. What is x? function funky(o) {\n o = null;\n}\nlet x = [];\nfunky(x);\nconsole.log(x); A.null\nB.[]\nC.undefined\nD.throw
\nslide13. What is x? function funky(o) {\n o = null;\n}\nlet x = [];\nfunky(x);\nconsole.log(x); A.null\nB.[]\nC.undefined\nD.throw
\nslide14. function funky(o) {\n o = null;\n}\nlet x = [];\nfunky(x);\nconsole.log(x); global [ ]
\nslide15. function funky(o) {\n o = null;\n}\nlet x = [];\nfunky(x);\nconsole.log(x); global [ ] funky
\nslide16. function funky(o) {\n o = null;\n}\nlet x = [];\nfunky(x);\nconsole.log(x); global [ ] funky
\nslide17. What is x? function swap(a, b) {\n let temp = a;\n a = b;\n b = temp;\n}\nlet x = 1;\nlet y = 2;\nswap(x, y);\nconsole.log(x); A.1\nB.2\nC.undefined\nD.throw
\nslide18. What is x? function swap(a, b) {\n let temp = a;\n a = b;\n b = temp;\n}\nlet x = 1;\nlet y = 2;\nswap(x, y);\nconsole.log(x); A.1\nB.2\nC.undefined\nD.throw
\nslide19. function swap(a, b) {\n let temp = a;\n a = b;\n b = temp;\n}\nlet x = 1;\nlet y = 2;\nswap(x, y);\nconsole.log(x); global 1 2
\nslide20. function swap(a, b) {\n let temp = a;\n a = b;\n b = temp;\n}\nlet x = 1;\nlet y = 2;\nswap(x, y);\nconsole.log(x); global 1 2 swap
\nslide21. function swap(a, b) {\n let temp = a;\n a = b;\n b = temp;\n}\nlet x = 1;\nlet y = 2;\nswap(x, y);\nconsole.log(x); global 1 2 swap
\nslide22. Write three binary functions, add , sub, and mul, that take two numbers and return their sum, difference, and product. add(3, 4) // 7\nsub(3, 4) // -1\nmul(3, 4) // 12
\nslide23. function add(first, second) {\n return first + second;\n}\n\nfunction sub(first, second) {\n return first - second;\n}\n\nfunction mul(first, second) {\n return first * second;\n}
\nslide24. Write a function identityf that takes an argument and returns a function that returns that argument. const unity = identityf(1);\nunity() // 1
\nslide25. function identityf(x) {\n return function () {\n return x;\n };\n}
\nslide26. Write a function addf that \u000badds from two invocations. addf(3)(4) // 7
\nslide27. function addf(first) {\n return function (second) {\n return first + second;\n };\n}
\nslide28. Write a function curry that takes a binary function and an argument, and returns a function that can take a second argument. let add3 = curry(add, 3);\nadd3(4) // 7\n\ncurry(mul, 5)(6) // 30
\nslide29. function curry(binary, first) {\n return function (second) {\n return binary(first, second);\n };\n}
\nslide30. function curry(binary, first) {\n return function (second) {\n return binary(first, second);\n };\n}\n\nfunction curry(func, first) {\n return liftf(func)(first);\n} currying\n\nschönfinkelisation
\nslide31. function curry(func) {\n const slice = Array.prototype.slice;\n const args = slice.call(arguments, 1);\n return function () {\n return func.apply(\n null, \n args.concat(slice.call(arguments, 0))\n );\n };\n}\n\nfunction curry(func, ...first) {\n return function (...second) {\n return func(...first, ...second);\n };\n}
\nslide32. function curry(func) {\n const slice = Array.prototype.slice;\n const args = slice.call(arguments, 1);\n return function () {\n return func.apply(\n null, \n args.concat(slice.call(arguments, 0))\n );\n };\n}\n\nfunction curry(func, ...first) {\n return function (...second) {\n return func(...first, ...second);\n };\n}
\nslide33. Write a function curryr that takes a binary function and a second argument, and returns a function that can take a" }

Fun With Functions Block Scope { let a; { let

Fun With Functions Block Scope { let a; { let
1 / 1
Fun With Functions Block Scope { let a; { let - slide 1 of 130 Fun With Functions Block Scope { let a; { let - slide 2 of 130 Fun With Functions Block Scope { let a; { let - slide 3 of 130 Fun With Functions Block Scope { let a; { let - slide 4 of 130 Fun With Functions Block Scope { let a; { let - slide 5 of 130 Fun With Functions Block Scope { let a; { let - slide 6 of 130 Fun With Functions Block Scope { let a; { let - slide 7 of 130 Fun With Functions Block Scope { let a; { let - slide 8 of 130 Fun With Functions Block Scope { let a; { let - slide 9 of 130 Fun With Functions Block Scope { let a; { let - slide 10 of 130 Fun With Functions Block Scope { let a; { let - slide 11 of 130 Fun With Functions Block Scope { let a; { let - slide 12 of 130 Fun With Functions Block Scope { let a; { let - slide 13 of 130 Fun With Functions Block Scope { let a; { let - slide 14 of 130 Fun With Functions Block Scope { let a; { let - slide 15 of 130 Fun With Functions Block Scope { let a; { let - slide 16 of 130 Fun With Functions Block Scope { let a; { let - slide 17 of 130 Fun With Functions Block Scope { let a; { let - slide 18 of 130 Fun With Functions Block Scope { let a; { let - slide 19 of 130 Fun With Functions Block Scope { let a; { let - slide 20 of 130 Fun With Functions Block Scope { let a; { let - slide 21 of 130 Fun With Functions Block Scope { let a; { let - slide 22 of 130 Fun With Functions Block Scope { let a; { let - slide 23 of 130 Fun With Functions Block Scope { let a; { let - slide 24 of 130 Fun With Functions Block Scope { let a; { let - slide 25 of 130 Fun With Functions Block Scope { let a; { let - slide 26 of 130 Fun With Functions Block Scope { let a; { let - slide 27 of 130 Fun With Functions Block Scope { let a; { let - slide 28 of 130 Fun With Functions Block Scope { let a; { let - slide 29 of 130 Fun With Functions Block Scope { let a; { let - slide 30 of 130 Fun With Functions Block Scope { let a; { let - slide 31 of 130 Fun With Functions Block Scope { let a; { let - slide 32 of 130 Fun With Functions Block Scope { let a; { let - slide 33 of 130 Fun With Functions Block Scope { let a; { let - slide 34 of 130 Fun With Functions Block Scope { let a; { let - slide 35 of 130 Fun With Functions Block Scope { let a; { let - slide 36 of 130 Fun With Functions Block Scope { let a; { let - slide 37 of 130 Fun With Functions Block Scope { let a; { let - slide 38 of 130 Fun With Functions Block Scope { let a; { let - slide 39 of 130 Fun With Functions Block Scope { let a; { let - slide 40 of 130 Fun With Functions Block Scope { let a; { let - slide 41 of 130 Fun With Functions Block Scope { let a; { let - slide 42 of 130 Fun With Functions Block Scope { let a; { let - slide 43 of 130 Fun With Functions Block Scope { let a; { let - slide 44 of 130 Fun With Functions Block Scope { let a; { let - slide 45 of 130 Fun With Functions Block Scope { let a; { let - slide 46 of 130 Fun With Functions Block Scope { let a; { let - slide 47 of 130 Fun With Functions Block Scope { let a; { let - slide 48 of 130 Fun With Functions Block Scope { let a; { let - slide 49 of 130 Fun With Functions Block Scope { let a; { let - slide 50 of 130 Fun With Functions Block Scope { let a; { let - slide 51 of 130 Fun With Functions Block Scope { let a; { let - slide 52 of 130 Fun With Functions Block Scope { let a; { let - slide 53 of 130 Fun With Functions Block Scope { let a; { let - slide 54 of 130 Fun With Functions Block Scope { let a; { let - slide 55 of 130 Fun With Functions Block Scope { let a; { let - slide 56 of 130 Fun With Functions Block Scope { let a; { let - slide 57 of 130 Fun With Functions Block Scope { let a; { let - slide 58 of 130 Fun With Functions Block Scope { let a; { let - slide 59 of 130 Fun With Functions Block Scope { let a; { let - slide 60 of 130 Fun With Functions Block Scope { let a; { let - slide 61 of 130 Fun With Functions Block Scope { let a; { let - slide 62 of 130 Fun With Functions Block Scope { let a; { let - slide 63 of 130 Fun With Functions Block Scope { let a; { let - slide 64 of 130 Fun With Functions Block Scope { let a; { let - slide 65 of 130 Fun With Functions Block Scope { let a; { let - slide 66 of 130 Fun With Functions Block Scope { let a; { let - slide 67 of 130 Fun With Functions Block Scope { let a; { let - slide 68 of 130 Fun With Functions Block Scope { let a; { let - slide 69 of 130 Fun With Functions Block Scope { let a; { let - slide 70 of 130 Fun With Functions Block Scope { let a; { let - slide 71 of 130 Fun With Functions Block Scope { let a; { let - slide 72 of 130 Fun With Functions Block Scope { let a; { let - slide 73 of 130 Fun With Functions Block Scope { let a; { let - slide 74 of 130 Fun With Functions Block Scope { let a; { let - slide 75 of 130 Fun With Functions Block Scope { let a; { let - slide 76 of 130 Fun With Functions Block Scope { let a; { let - slide 77 of 130 Fun With Functions Block Scope { let a; { let - slide 78 of 130 Fun With Functions Block Scope { let a; { let - slide 79 of 130 Fun With Functions Block Scope { let a; { let - slide 80 of 130 Fun With Functions Block Scope { let a; { let - slide 81 of 130 Fun With Functions Block Scope { let a; { let - slide 82 of 130 Fun With Functions Block Scope { let a; { let - slide 83 of 130 Fun With Functions Block Scope { let a; { let - slide 84 of 130 Fun With Functions Block Scope { let a; { let - slide 85 of 130 Fun With Functions Block Scope { let a; { let - slide 86 of 130 Fun With Functions Block Scope { let a; { let - slide 87 of 130 Fun With Functions Block Scope { let a; { let - slide 88 of 130 Fun With Functions Block Scope { let a; { let - slide 89 of 130 Fun With Functions Block Scope { let a; { let - slide 90 of 130 Fun With Functions Block Scope { let a; { let - slide 91 of 130 Fun With Functions Block Scope { let a; { let - slide 92 of 130 Fun With Functions Block Scope { let a; { let - slide 93 of 130 Fun With Functions Block Scope { let a; { let - slide 94 of 130 Fun With Functions Block Scope { let a; { let - slide 95 of 130 Fun With Functions Block Scope { let a; { let - slide 96 of 130 Fun With Functions Block Scope { let a; { let - slide 97 of 130 Fun With Functions Block Scope { let a; { let - slide 98 of 130 Fun With Functions Block Scope { let a; { let - slide 99 of 130 Fun With Functions Block Scope { let a; { let - slide 100 of 130 Fun With Functions Block Scope { let a; { let - slide 101 of 130 Fun With Functions Block Scope { let a; { let - slide 102 of 130 Fun With Functions Block Scope { let a; { let - slide 103 of 130 Fun With Functions Block Scope { let a; { let - slide 104 of 130 Fun With Functions Block Scope { let a; { let - slide 105 of 130 Fun With Functions Block Scope { let a; { let - slide 106 of 130 Fun With Functions Block Scope { let a; { let - slide 107 of 130 Fun With Functions Block Scope { let a; { let - slide 108 of 130 Fun With Functions Block Scope { let a; { let - slide 109 of 130 Fun With Functions Block Scope { let a; { let - slide 110 of 130 Fun With Functions Block Scope { let a; { let - slide 111 of 130 Fun With Functions Block Scope { let a; { let - slide 112 of 130 Fun With Functions Block Scope { let a; { let - slide 113 of 130 Fun With Functions Block Scope { let a; { let - slide 114 of 130 Fun With Functions Block Scope { let a; { let - slide 115 of 130 Fun With Functions Block Scope { let a; { let - slide 116 of 130 Fun With Functions Block Scope { let a; { let - slide 117 of 130 Fun With Functions Block Scope { let a; { let - slide 118 of 130 Fun With Functions Block Scope { let a; { let - slide 119 of 130 Fun With Functions Block Scope { let a; { let - slide 120 of 130 Fun With Functions Block Scope { let a; { let - slide 121 of 130 Fun With Functions Block Scope { let a; { let - slide 122 of 130 Fun With Functions Block Scope { let a; { let - slide 123 of 130 Fun With Functions Block Scope { let a; { let - slide 124 of 130 Fun With Functions Block Scope { let a; { let - slide 125 of 130 Fun With Functions Block Scope { let a; { let - slide 126 of 130 Fun With Functions Block Scope { let a; { let - slide 127 of 130 Fun With Functions Block Scope { let a; { let - slide 128 of 130 Fun With Functions Block Scope { let a; { let - slide 129 of 130 Fun With Functions Block Scope { let a; { let - slide 130 of 130
Fun With Functions Block Scope let a; let b; a b a Function Scope function green() let a; function yellow() let b; a b a Function Scope function green() let a; function yellow() let b; a

Related Topics

Download this presentation From Below

"Fun With Functions Block Scope { let a; { let" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
Fun With Functions<br>
02
Block Scope {
let a;
{
let b;
… a …
… b …
}
… a …
}<br>
03
Function Scope function green() {
let a;
function yellow() {
let b;
… a …
… b …
}
… a …
}<br>