MADCON 2017 Talk
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
| function smash(array) { | |
| var smashedArr = []; | |
| //in this loop, "block" is the first ele of the array | |
| // condition - checks that block is not undefiend/end of array | |
| for (var block = array.shift(); block !== undefined; block = array.shift()) { | |
| //check true | |
| switch(true){ | |
| //that the given "block" is an array | |
| case (Array.isArray(block)): | |
| //TRUE -- add the block to the front of the array |
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
| (function () { | |
| var defaultArr = [1, { | |
| obj_a: 1 | |
| }, | |
| [4, [{ | |
| obj_c: 'object value' | |
| }]], 6, 7, [8, { | |
| obj_b: 2 | |
| }, { | |
| obj_d: 1977 |
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
| Array.prototype.getUnique = function() { | |
| var base = this; | |
| var arr = []; | |
| for (var i = 0; i < base.length; i++) { | |
| for (var j = i + 1; j < base.length; j++) { | |
| if (base[i] === base[j]) { | |
| j = ++i; | |
| } | |
| } | |
| arr.push(base[i]); |