“-1 в JavaScript” Ответ

-1 в 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 в JavaScript


!0 = true
!1 = false

Wrong Wryneck

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

Ответы похожие на “-1 в JavaScript”

Вопросы похожие на “-1 в JavaScript”

Больше похожих ответов на “-1 в JavaScript” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования