<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie-edge">
<title>Document</title>
<script>
// 检测获取字符串的长度 length
var str = 'my name is andy' ;
console.log(str.length);//15
// 2.字符串的拼接 只要有字符串和其他类型相拼接 最终的结果是字符串类型
console.log('沙漠' + '骆驼');//沙漠骆驼
console.log('pinkl老师' + 18 ) ;//pink老师18
console.log('pink' + true );//pinktrue
console.log(12 + 12) ;//24
console.log('12' + 12 );//1212
// 1.1字符串“相加”
alert('hello' + ' ' + 'word' );//hello word
// 1.2数值字符串“相加”
alert('100' + '100' );//100100
// 1.3数值字符串+数值
alert('11' + 12 );//1112
//总结口诀 :数值相加,字符相连
</script>
</head>
<body>
</body>
</html>
学习自b站【JavaScript基础语法-dom-bom-js-es6新语法-jQuery-数据可视化echarts黑马pink老师前端入门基础视频教程(500多集)持续-哔哩哔哩】 https://b23.tv/YGIdOrv