“-1 em JS” Respostas de código

-1 em 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 em 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

Respostas semelhantes a “-1 em JS”

Perguntas semelhantes a “-1 em JS”

Mais respostas relacionadas para “-1 em JS” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código