Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

The array is “empty”

Slide 8

Slide 8 text

Section 11.8.7 toString relies on join (Section 15.4.4.5) join convertes undefined or null to an empty string

Slide 9

Slide 9 text

The array is filled with undefined

Slide 10

Slide 10 text

Array Parameters http://www.2ality.com/2011/08/spreading.html Section 15.3.4.3

Slide 11

Slide 11 text

“ghost elements” got converted into undefined

Slide 12

Slide 12 text

Section 15.4.4.19 map calls callbackfn once for each element in the array, in ascending order, and constructs a new Array from the results. callbackfn is called with three arguments: ● the value of the element ● the index of the element, and ● the object being traversed.

Slide 13

Slide 13 text

y = index x = element

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

“Sequences using JavaScript Array” http://ariya.ofilabs.com/2013/07/sequences-using-javascript-array.html

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

http://en.wikipedia.org/wiki/Primality_test Can we divide i by c?

Slide 19

Slide 19 text

isPrime(23) Math.sqrt(23) = 4.79583 23 % 2 = 1 23 % 3 = 2 23 % 4 = 3 true isPrime(27) Math.sqrt(27) = 5.1961 27 % 2 = 1 27 % 3 = 0 27 % 4 = 3 27 % 5 = 2 false

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Section 15.4.4.16 every calls callbackfn once for each element present in the array, in ascending order, until it finds one where callbackfn returns false. If such an element is found, every immediately returns false. Otherwise, if callbackfn returned true for all elements, every will return true.

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

~~ is Math.floor Can we divide i by y?

Slide 25

Slide 25 text

Section 15.4.4.20 filter calls callbackfn once for each element in the array, in ascending order, and constructs a new array of all the values for which callbackfn returns true. callbackfn is called with three arguments: ● the value of the element ● the index of the element, and ● the object being traversed.

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

0..N-1 Primality test

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Section 15.4.4.21 callbackfn is called with four arguments: ● the previousValue (or value from the previous call to callbackfn), ● the currentValue (value of the current element) ● the currentIndex, and ● the object being traversed.

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

0..N-1 Accumulate

Slide 33

Slide 33 text

x z 1 1 0 2 1 6 2 24 3 120 4

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

“..the growth of an idealized (biologically unrealistic) rabbit population..” http://en.wikipedia.org/wiki/Fibonacci_number

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Two previous numbers

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

“Prime Numbers, Factorial, and Fibonacci Series with JavaScript Array” http://ariya.ofilabs.com/2013/07/prime-numbers-factorial-and-fibonacci- series-with-javascript-array.html

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

“Searching with Array.prototype.some” http://ariya.ofilabs.com/2013/08/searching-with-array-prototype-some.html “Searching using Array.prototype.reduce” http://ariya.ofilabs.com/2013/10/searching-using-array-prototype-reduce.html

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

“Sorting Networks using Higher-Order Functions of JavaScript Array” http://ariya.ofilabs.com/2013/10/sorting-networks-using-higher-order- functions-of-javascript-array.html “Searching using Array.prototype.reduce” http://ariya.ofilabs.com/2013/10/searching-using-array-prototype-reduce.html

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

dysfunctional programming

Slide 51

Slide 51 text

No content