js 中的一元運算符"~"有哪些應用?

~ :按位取反性能 應用:class 取整:~~1.2 //1 比 parseInt、Math.floor 性能快 用 ~someArray.indexOf(someValue) 代替 someArray.indexOf(someValue) !== -1,由於 ~-1=0,因此能夠利用這一點去作判斷。
相關文章
相關標籤/搜索