隐式转换 数字字符串加数字,数字隐式转换为字符串
console
.log(30+'30');
console
.log('30'+30);
数字字符串与数字做非加法运算,字符串隐式转换为数字
console
.log('20'-10);
console
.log(10*'10');
console
.log(10/'2');
数字字符串与数字字符做非加法运算,隐式转换为数字
console
.log('20'-'10');
console
.log('20'/'10');
console
.log('20'*'10');
强制类型转换 整数字符串转换为整数
let number
= '20';
let number1
= parseInt(number
);
console
.log(number1
);
console
.log(typeof number2
);