Javascript获取字符串的长度用 字符串.length
示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
const str = '繁华的地方'
console.log(str.length)
</script>
</body>
</html>
控制台显示了字符串的长度: