我是java-script的新手,无法理解|的用法以下代码段中的运算符
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display a number between 0 and 1</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var a=Math.random();
var x = ((a*2 | 0));
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
&#13;
答案 0 :(得分:1)