Home > Web Front-end > JS Tutorial > body text

Example analysis of adding numbers and strings in javascript_javascript skills

WBOY
Release: 2016-05-16 18:03:37
Original
1883 people have browsed it
复制代码 代码如下:

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("")
假如i=1,以上代码输出为
如果想输出为2.jpg,应该这样写
document.write("")
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template