1. поп, толкать, сдвигать, не сдвигать, нарезать, сращивать

Пример ниже покажет, как я манипулирую массивом с помощью функций pop, push, shift, unshift, slice, splice. См. ниже.

const char = ["a", "b", "c"];
console.log(char); // [ 'a', 'b', 'c' ]
char.pop(); // remove last
console.log(char); // [ 'a', 'b' ]
char.push("8", "9"); // add from behind
console.log(char); //[ 'a', 'b', '8', '9' ]
char.shift(); // remove first
console.log(char); // [ 'b', '8', '9' ]
char.unshift("1", "2"); // add from front
console.log(char); // [ '1', '2', 'b', '8', '9' ]

//    0    1    2    3    4
// [ '1', '2', 'b', '8', '9' ]
const charSlice = char.slice(2, 4); // copy 'b', '8' from array
console.log(charSlice); // [ 'b', '8' ]
char.splice(1, 3); // remove '2', 'b', '8' from array
console.log(char); // [ '1', '9' ]

2. Массив.от

Array.from должен создать массив из строки. См. ниже.

//Array.from - create array from string
console.log(Array.from("abce")); //[ 'a', 'b', 'c', 'e' ]
console.log(Array.from("1234", (x) => parseInt(x) + 2)); //[ 3, 4, 5, 6 ]

3. Массив.из

Array.of — создать массив из аргументов. См. ниже.

//Array.of - create array from arguments
console.log(Array.of("a", 1, "b", 2, "c", 3, true, { a: 1, b: 2 })); 
//result -> [ 'a', 1, 'b', 2, 'c', 3, true, { a: 1, b: 2 } ]

4. копировать внутри

copyWithin — это копирование некоторых значений в массиве. См. ниже.

//copyWithin
const char1 = ["a", "b", "c", "d", "e"];
console.log(char1.copyWithin(1, 0)); //replace 2nd with 1st
//result -> [ 'a', 'a', 'b', 'c', 'd' ]

const char2 = ["a", "b", "c", "d", "e"];
console.log(char2.copyWithin(2, 4)); //replace 3rd with 4th
//result -> [ 'a', 'b', 'e', 'd', 'e' ]

const char3 = ["a", "b", "c", "d", "e", "f", "g", "h"];
console.log(char3.copyWithin(4, 0, 3)); //replace 5th onwards with 1st, 2nd, 3rd
//result -> [ 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'h']