Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

-1 in 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
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 :: Ant Media Filter Plugin for Text 
Javascript :: getting json from response using getSync method 
Javascript :: AngularJS Graphs & Charts - Mix of solid & dotted 
Javascript :: node js delete folder 
Javascript :: Changing the value of a dropdown when the value of a number box changes in AngularJS 
Javascript :: AngularJs: How to interpolate an interpolated string 
Javascript :: DeepCopy in Angularjs 
Javascript :: How to call keyup function on textbox for every dynamic generated form in Angular8 
Javascript :: AngularJS disable default form submit hook 
Javascript :: when selecting second dropdown ng-model object return null 
Javascript :: How to query a button with specific text with react native testing library 
Javascript :: javascript unique grouped arrays 
Javascript :: Undefined value document.getElementById 
Javascript :: js generate pnh 
Javascript :: how to build a nested, dynamic JSON in Go 
Javascript :: image react not showing 
Javascript :: convert json to string curl 
Javascript :: javascript datamatrix parser 
Javascript :: how to set socket io into global express 
Javascript :: phaser time event start at 
Javascript :: vimscript replace function 
Javascript :: javascript check if a number starts with another number 
Javascript :: javascript reverse string short hand 
Javascript :: number of substring in a string 
Javascript :: Joi conditional validation refer parent object 
Javascript :: prisma write database 
Javascript :: Control a progress bar for custom video player 
Javascript :: required field in javascript dynamically 
Javascript :: In express redirect user to external url 
Javascript :: javascript for backend 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =