Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用JavaScript 的按位1或等于运算符创建 polyfill 有什么问题|=吗?
|=
Date.now |= function() { return +new Date; };
1位运算符参考 2Date.now()参考
Date.now()
嗯,是吗?和之间有一个主要区别|,||polyfills 应该使用:
|
||
Date.now = Date.now || function() {return +new Date;};
毕竟,如果你使用这个:
Date.now = Date.now | function() {return +new Date;};
你会得到0覆盖函数的结果。
0