Пустой массив путем замены нового массива
JavaScript
xxxxxxxxxx
function emptyArray(arr) {
arr = [];
return arr;
}
const array = [1, 2 ,3];
console.log(array);
const result = emptyArray(array);
console.log(result);
[1, 2, 3] []
splice()
JavaScript
xxxxxxxxxx
function emptyArray(arr) {
arr.splice(0, arr.length);
return arr;
}
const array = [1, 2 ,3];
console.log(array);
const result = emptyArray(array);
console.log(result);
[1, 2, 3] []
Пустой массив, установив длину 0
JavaScript
xxxxxxxxxx
function emptyArray(arr) {
arr.length = 0;
return arr;
}
const array = [1, 2 ,3];
console.log(array);
const result = emptyArray(array);
console.log(result);
[1, 2, 3] []
Linux - Как установить anc-api-tools
Linux - Как установить curvedns
Python - Проверьте, является ли число положительным, отрицательным или 0
Linux - Как установить zenmap
C - Подсчитать количество цифр в целом числе
C++ - Проверить високосный год
JavaScript - Проверьте, начинается ли строка и заканчивается ли она определенными символами
C++ - Проверить, является ли число простым или нет
C - Найдите наибольшее число, используя динамическое выделение памяти
Kotlin - Округлить число до n знаков после запятой
Linux - Как установить xbitmaps
Linux - Как установить zstd
Kotlin - Перевернуть число
Java - Перевернуть число
Python - Запись файлов Excel (XLSX)
C++ - Найти частное и остаток
Linux - Как установить zfs-test
Java - Создайте пирамиду и узор
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month