在 JavaScript 中“双波浪号” (~~) 运算符是什么?
“双波浪号” (~~) 运算符是双非位运算符。用它来代替 Math.floor(),因为它更快。
举例
你可以尝试运行以下代码来了解双波浪号运算符 −
<html>
<body>
<script>
var a = 2;
var b,c, d;
b = ~~a;
c = Math.floor(a);
d = ~~b=== c;
document.write(b);
document.write("<br>"+c);
document.write("<br>"+d); // They are equal
</script>
</body>
</html>
广告
数据结构
网络
关机数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程语言
C++
C#
MongoDB
MySQL
Javascript
PHP