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

...