抛出问题
-
0.1 + 0.2 === 0.3 -----> false 为啥?😒
-
框架、轮子源码里的位运算到底啥意思?
// React源码 function clz32Fallback(x: number): number { const asUint = x >>> 0; if (asUint === 0) { return 32; } return (31 - ((log(asUint) / LN2) | 0)) | 0; } // Vue源码 function repeat(str: string, n: number) { let result = '' if (n > 0) { // eslint-disable-next-line no-constant-condition while (true) { // eslint-disable-line if (n & 1) result += str n >>>= 1 if (n <= 0) break str += str } } return result }
-
以上两个问题如果知道答案, 请略过本文
大约 9 分钟