javascript using the unary-plus and unary-minus operator 一元操作符

新手入门啊,看看就明白了!

  
    
< script src = ' jquery.js ' >< / script>
......
< script >
var a = 1 ;
var b = ' 2 ' ;

// output number
console.log( typeof ( - b));
console.log(
typeof ( + b));
// output string
console.log( typeof (b));

// output 12
console.log(a + b);

// output 3
console.log(a + Number(b));
console.log(a
+ + b);
console.log(a
- - b);

// output -1
console.log(a + - b);
console.log(a
- + b);
< / script>

你可能感兴趣的:(JavaScript)