代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>隐式转换</title>
</head>
<body>
<script>
// // 第一个数字
// let num1 = +prompt('请输入第一个月工资:')
// // // 第二个数字
// let num2 = +prompt('请输入第二个月工资:')
// // // 输出结果
// alert(num1 + num2)
// 1. 隐式转换为数字型的运算符
// 1.1 算术运算符 - * / % 比较运算符 > ==
// console.log('10' - '5') // 5
// console.log(10 - '50px') // NaN
// console.log(10 * '100') // 1000
// console.log('10' + 10) // 1010
// console.log(100 > '10') // true
// console.log(100 == '100') // true
// 1.2 + 正号使用的时候,也会把字符串转换为 数字型
// console.log(typeof +'100')
// console.log( +'100px')
// 2. 隐式转换为字符串型的运算符
// + 运算符左边或者右边只要有个是字符串, 都会转成字符串来拼接
// console.log(10 + '10') // '1010'
// console.log('abc' + 100) // 'abc100'
// console.log('' + 10086) // '10086'
// 3. 隐式转换为布尔型的运算符 !逻辑非
// 0 '' undefined null NaN false
console.log(!0) // true
console.log(!'') // true
console.log(!undefined) // true
console.log(!null) // true
console.log(!NaN) // true
console.log(!false) // true
console.log(!'abc') // false
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。