Operations on Numbers & Strings

var a=1;
var b="2";

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

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


一元加号操作符也可以做到强制转换
console.log(a+ +b); //3

 

posted @ 2013-12-20 10:59  嘣嘣  阅读(136)  评论(0编辑  收藏  举报