Posted in Javascript onAugust 14, 2011
console.log('----1----') console.log('12' + '34')//'1234' console.log('12' + 34 )//'1234' console.log(12 + '34')//'1234' console.log(12 + 34 )//46 console.log('----2----') console.log(+'12' + '34')//'1234' console.log(+'12' + 34 )//46 console.log(+12 + '34')//'1234' console.log(+12 + 34 )//46 console.log('----3----') console.log(-'12' + '34')//'-1234' console.log(-'12' + 34)//22 console.log(-12 + '34')//'-1234' console.log(-12 + 34)//22 console.log('----4----') console.log('12' - '34')//-22 console.log('12' - 34)//-22 console.log(12 - '34')//-22 console.log(12 - 34)//-22 console.log('----5----') console.log(+'12' - '34')//-22 console.log(+'12' - 34)//-22 console.log(+12 - '34')//-22 console.log(+12 - 34)//-22 console.log('----6----') console.log(-'12' - '34')//-22 console.log(-'12' - 34)//-22 console.log(-12 - '34')//-22 console.log(-12 - 34)//-22
javascript中字符串连接的同时数字相加
document.write("<img src='images/" + i + 1 + ".jpg'>")
假如i=1,以上代码输出为<img src='images/11.jpg'>
如果想输出为2.jpg,应该这样写
document.write("<img src='images/" + (i+1) + ".jpg'>")
javascript中的数字与字符串相加实例分析
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@