(function(y){ }(i))
() => { console.log(y) }
Насколько я знаю, _ в JS является валидным именем переменной, такую переменную можно создать, обращаться к ней и т.д. Так получается что я просто передаю в ф-цию неиспользуемую переменную?? Тоже самое как сделал бы a => { ... } ??Именно так.
() => { ... }
по ряду причин:a => { ... }
, только (a) => { ... }
. И банально проще, когда у тебя весь код по разным проектам в одном стиле. Number()
при вызове как функции, конвертирует аргумент в численный тип. Если не получается, возвращает NaN
(Not A Number) – специальное значение, которое при конвертации в булев даёт false
. (! Number(value))
сработает когда переданное не перевести в число, или когда число 0
.Number()
довольно строг с конвертацией в число, по сравнению даже с parseInt()
:parseInt("123HabraHabr") // 123
Number("123HabraHabr") // NaN
Number()
проглотил бы как число, но при этом она содержала код, который JS как-то интерпретирует. Типа '123 & alert("Habr!")'
– но нет, через Number()
это не пролезет, увы. res.redirect('/');
return;
Object.assign({}, [1,2,3,4,5]); // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
Object.assign({}, ['a','b','c']); // {0: "a", 1: "b", 2: "c"}
{...[1,2,3,4,5]} // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
Object.fromEntries(Object.entries([1,2,3,4])); // {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
const isSumEven = arr => arr.reduce((p, c) => p ^ c, 1) & 1;
// или
const isSumEven = arr => !(arr.filter(n => n % 2).length % 2);
// или
const isSumEven = arr => Number.isInteger(arr.reduce((acc, n) => acc + n, 0) / 2);
// или
const isSumEven = arr => /[02468]$/.test(eval(arr.join('+')) ?? 0);
const result = arr.filter(isSumEven);
. function split(arr, numParts) {
const partSize = arr.length / numParts | 0;
return Array
.from({ length: numParts }, (n, i) => i * partSize)
.map((n, i, a) => arr.slice(n, a[i + 1]));
}
function split(arr, numParts) {
const partSize = arr.length / numParts | 0;
const numLooseItems = arr.length % numParts;
return Array.from(
{ length: numParts },
function(_, i) {
return arr.slice(this(i), this(i + 1));
},
i => i * partSize + Math.min(i, numLooseItems)
);
}
Please provide an email response specifically identifying the country in which the [Product Name] Software is developed and maintained.В письме укажите свою страну...
If the country of origin is outside the United States, please provide any information you may have stating that testing is performed in the United States prior to supplying products to customers....скажите, что вы никакого тестирования в США не проводили, а про других ничего не знаете...
Additionally, if available, please identify all authorized resellers of the product in question....поскольку ПО свободное, никто его не перепродаёт...
Lastly, please confirm that the product(s) in question is not manufactured by, contain critical components developed by, or receive substantial political or monetary influence from entities prohibited by Section 889 of the 2019 NDAA....никакую из перечисленных компаний вы не знаете и денег от них не получали.
Как исправить баг?