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 中的运算符?
什么是 not not in javascript 我已经看过几次了 :)
function foo(){ return !!(window.history); }
我相信它用于强制布尔类型......
例如
if("true" == true){ alert("1"); }else{ if(!!"true" == true){ alert("2"); } }
警报 2 不是 1
我认为它曾经 [不是这样] 隐式地将值转换为布尔类型