📜  javascript代码示例中的-1

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

代码示例1
// in JavaScript negative numbers are written the same as regular numbers
var negativeone = -1;
console.log(negativeone); // -> -1
// the subtraction symbol means the computer subtracts the number on
// the left from the number on the right, if there is no number on
// the right it is the same as 0
// or in other words -1 = 0 - 1
console.log(-1 === 0 - 1);  // -> true
// you can also do the same with variables
console.log(-negativeone); // -> 1