Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

-1 in 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
Comment

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


Comment

-1 in javascript


!0 = true
!1 = false

Comment

PREVIOUS NEXT
Code Example
Javascript :: js painting app 
Javascript :: next field 
Javascript :: js match property 
Javascript :: best way to store db config in node js 
Javascript :: preview.cookie-consent.js 
Javascript :: change event when click multiple revit api 
Javascript :: window.getselection outside 
Javascript :: scroll to a input on button click react native 
Javascript :: angular copy folder to dist 
Javascript :: laravel tabel json nullable 
Javascript :: queen of spain 
Javascript :: maximum element in an array javascript 
Javascript :: how to create a variable with a operator in javascript 
Javascript :: compile pdf with javascript 
Javascript :: Node temp = new Node(6, head, head.getNext()); head.setNext(temp); temp.getNext().setPrev(temp); Node temp1 = tail.getPrev(); tail.setPrev(temp1.getPrev()); temp1.getPrev().setNext(tail); 
Javascript :: ejs toggle class 
Javascript :: javascript onclick event add html element 
Javascript :: add onmouseover event in javascript 
Javascript :: what is the purpose of the super(props) method in React 
Javascript :: what does bang at the end of a statement mean for in typescript 
Javascript :: convert componentDidUpdate into useEffect 
Javascript :: como saber si un afecha es mayor o menor js 
Javascript :: javascript array get element by index 
Javascript :: when reload the page the route gone in react js laravel 
Javascript :: animating using jquery 
Javascript :: react foreach loop 
Javascript :: react navigation tabs up in keyboard 
Javascript :: flyweight 
Javascript :: Import Bootstrap to React Redux CRUD App 
Javascript :: checkout code 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =