64 Arrays methods

Run Settings
LanguageJavaScript
Language Version
Run Command
const strings = ['a', 'b', 'c', 'd']; // 4*4 = 16 bytes of storage in a 32-bit sustem // LOOKUP O(1) // console.log(strings[2]); // O(1) // Methods we can add in arrays // PUSH O(1) - add item to end of an array strings.push('e'); // O(1). [ 'a', 'b', 'c', 'd', 'e' ] // Pop - remove last item in the array strings.pop(); // O(1) [ 'a', 'b', 'c', 'd' ] // INSERT O(n): Unshift - add item in the beginning of an array strings.unshift('x'); // O(n) [ 'x', 'a', 'b', 'c', 'd' ] // DELETE O(n): Splice - insert an item at a position, optionally either // deleting the previous item or moving it towards the end strings.splice(2, 0, 'alien'); // O(n) [ 'x', 'a', 'alien', 'b', 'c', 'd' ] console.log(strings);
Editor Settings
Theme
Key bindings
Full width
Lines