除法运算符 (/
) 计算了两个操作数的商,左边的数是被除数,右边的是除数
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
语法
Operator: x / y
例子
基本除法
1 / 2 // 0.5
Math.floor(3 / 2) // 1
1.0 / 2.0 // 0.5
除以0
2.0 / 0 // Infinity
2.0 / 0.0 // Infinity, because 0.0 === 0
2.0 / -0.0 // -Infinity
规范
Specification |
---|
ECMAScript (ECMA-262) Division operator |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.