1. isArray

isArray, чтобы узнать, является ли ваш входной параметр типом Array. См. ниже.

//isArray
console.log(Array.isArray([1, 2, 3])); //true
console.log(Array.isArray("a")); //false
console.log(Array.isArray(1)); //false
console.log(Array.isArray(true)); //false

2. at

at — показать значение массива по индексу. Отрицательный индекс — это обратный порядок. См. ниже.

//at
const char = ["a", "b", "c", "d", "e"];
console.log(char.at(0)); //a
console.log(char.at(1)); //b
console.log(char.at(2)); //c
console.log(char.at(3)); //d
console.log(char.at(4)); //e
console.log(char.at(5)); //undefiend
console.log(char.at(-1)); //e
console.log(char.at(-2)); //d
console.log(char.at(-3)); //c
console.log(char.at(-4)); //b
console.log(char.at(-5)); //a
console.log(char.at(-6)); //undefiend

3. длина

length — узнать длину массива. См. ниже.

//length
const no = [1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(no.length); //9

const char = ["a", "b"];
console.log(char.length); //2

4. конкат

concat - это объединение массивов. См. ниже.

//concat
const char1 = ["a", "b"];
const char2 = ["c", "d"];
console.log(char1.concat(char2)); //[ 'a', 'b', 'c', 'd' ]

5. присоединиться

join состоит в том, чтобы взять все значения массива и объединить их в строку с префиксом. См. ниже.

//join
const char = ["a", "b", "c", "d", "e", "f"];
console.log(char.join("-")); //a-b-c-d-e-f
console.log(char.join(",")); //a,b,c,d,e,f
console.log(char.join("|")); //a|b|c|d|e|f

6. сортировать

sort — сортировать значение массива в порядке возрастания. См. ниже.

//sort
const no = [3, 2, 4, 5, 1];
console.log(no.sort()); //[ 1, 2, 3, 4, 5 ]

7. реверс

reverse — отсортировать значение массива в порядке убывания. См. ниже.

//reverse
const char = ["a", "b", "c", "d", "e", "f"];
console.log(char.reverse()); //[ 'f', 'e', 'd', 'c', 'b', 'a' ]

8. заполнить

fill — сбросить все значения массива. См. ниже.

//fill
const no = [1, 2, 3, 4, 5];
const noFill = no.fill(0);
console.log(noFill); //[ 0, 0, 0, 0, 0 ]