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 187 views
1 answer 174 views
1 answer 213 views
1 answer 146 views
146 views asked Jan 9, 2016 by avibootz
...