powersOfTwo(0) // [1]
powersOfTwo(1) //[1, 2]
powersOfTwo(4) // [1, 2, 4, 8, 16]
function powersOfTwo(n) {
return Array.from({length: n + 1}, (v, k) => 2 ** k);
}
这里的2**k是怎么理解?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
es7 特性
Exponentiation
表示2的k次方