“-1 di JS” Kode Jawaban

-1 di JS

// 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
MattDESTROYER

-1 di JavaScript



let c = 0;

console.log(c + 1); // outputs 1

console.log(c); outputs 0, since in the last statement you didn't changed the original value, just used it.

console.log(c++); // will output c then increment c. So it prints the old value: 0

console log(c); will output 1 (result of previous increment)

console.log(++c); // will increment c and then output it new value: 2


Puzzled Peacock

Jawaban yang mirip dengan “-1 di JS”

Pertanyaan yang mirip dengan “-1 di JS”

Lebih banyak jawaban terkait untuk “-1 di JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya