Создание двухмерного массива, инициализированного с помощью нулей
const nrows = 5;
const ncols = 5;
const arr = Array.from({ length: nrows }, () =>
Array.from({ length: ncols }, () => 0)
);
Сглаживание двухмерного массива в 1D массив
const oneD = [].concat(...twoDArr);
Array.from () иногда может быть очень удобно
const primes = [2, 3, 5, 7, 11]; const sqPrimes = Array.from(primes, (x) => x * x);
Оригинал: “https://dev.to/ssmkhrj/few-neat-js-snippets-2c6j”