Last active
December 28, 2018 21:32
-
-
Save paolobueno/706604a19b31b85b3cebcb53d3fc1b9f to your computer and use it in GitHub Desktop.
array scratchpad
This file contains hidden or 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 a = [1, 2]; | |
| a; | |
| const mult = (x => (y => x * y)); | |
| const mult2 = mult(2); | |
| // function mult2 (x) { | |
| // return x * 2; | |
| // } | |
| console.log(mult(4)); | |
| console.log(mult2(4)); | |
| const c = a.map(mult).map(f => f(5)); | |
| c; | |
| a; | |
| var b = [ | |
| function apple(){}, | |
| function () {}, | |
| () => 'apple', | |
| ]; | |
| const bananas = [1, 2, 3]; | |
| console.log(bananas.map(mult(5))); | |
| for (let i = 0; i < bananas.length; i++) { | |
| console.log(mult(5)(bananas[i])); | |
| } | |
| console.log(typeof 2); | |
| console.log(typeof b); | |
| const y = function() {return 2}; | |
| console.log(y()); | |
| console.log(typeof b[2]); | |
| const w = b.forEach(function(f) { | |
| console.log(f()); | |
| }); | |
| console.log(w); | |
| const arr = [ | |
| [1, 2, 3], | |
| ['x', 'y', 'z'], | |
| ]; | |
| const x = {nome: 'pedro', idade: 2}; | |
| console.log(x.nome); | |
| const subArray = arr[1]; | |
| console.log(subArray); | |
| console.log(subArray[2]); | |
| console.log( (arr[1])[2] ) | |
| // Queue: FIFO -> First In First Out | |
| const fila = []; | |
| fila.push('cliente1'); | |
| fila.push('cliente2'); | |
| console.log(fila); | |
| function atenderCliente(c) { | |
| console.log(`atendido client ${c}`); | |
| } | |
| atenderCliente(fila.shift()); | |
| atenderCliente(fila.shift()); | |
| // Stack: LIFO -> Last In First Out | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment