1 in javascript

Solutions on MaxInterview for 1 in javascript by the best coders in the world

showing results for - " 1 in javascript"
Pablo
20 Aug 2020
1// in JavaScript negative numbers are written the same as regular numbers
2var negativeone = -1;
3console.log(negativeone); // -> -1
4// the subtraction symbol means the computer subtracts the number on
5// the left from the number on the right, if there is no number on
6// the right it is assumed 0
7// essentially -1 = 0 - 1
8console.log(-1 === 0 - 1);  // -> true
9// you can also do the same with variables
10console.log(-negativeone); // -> 1