Web*_*ner -1 javascript bit-manipulation cross-browser operators polyfills
使用JavaScript的按位1或等于运算符创建polyfill有什么问题|=吗?
Date.now |= function() {
return +new Date;
};
Run Code Online (Sandbox Code Playgroud)
嗯,是吗?|和之间存在重大差异||,并且polyfill应该使用:
Date.now = Date.now || function() {return +new Date;};
Run Code Online (Sandbox Code Playgroud)
毕竟,如果您使用此:
Date.now = Date.now | function() {return +new Date;};
Run Code Online (Sandbox Code Playgroud)
你会得到0覆盖函数的结果.