How to use unary negation (-) operator in JavaScript

1 Answer

0 votes
const x = 5;
const y = -x;

console.log(y);

const a = '7';
const b = -a;

console.log(b);

 
  
 
/*
run:
 
-5
-7
 
*/

 



answered Nov 18, 2020 by avibootz

Related questions

1 answer 163 views
1 answer 163 views
1 answer 144 views
1 answer 186 views
1 answer 173 views
1 answer 213 views
1 answer 145 views
145 views asked Jan 9, 2016 by avibootz
...