“-1 en javascript” Réponses codées

-1 en javascript

// 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 en javascript


!0 = true
!1 = false

Wrong Wryneck

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

Réponses similaires à “-1 en javascript”

Questions similaires à “-1 en javascript”

Plus de réponses similaires à “-1 en javascript” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code