📜  js % - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:43.205000             🧑  作者: Mango

代码示例6
/*The remainder operator (%) returns the remainder left 
over when one operand is divided by a second operand. 
It always takes the sign of the dividend.*/
console.log(12 % 5);
// expected output: 2

console.log(-12 % 5);
// expected output: -2

console.log(4 % 2);
// expected output: 0

console.log(-4 % 2);
// expected output: -0