<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>字符串</title>
</head>
<body>
<script>
/* 定义字符串 */
var str0 = new String("halo");
var str = " hello string! ";
console.log(str);
/* 获取字符串长度 */
console.log(str.length);
/* 返回指定位置的字符串 */
console.log(str.charAt(11));
/* 检索字符串 */
console.log(str.indexOf('tr'));
/* 去除字符串两边的空格 */
s=str.trim();
console.log(s);
/* 提取字符串中两个指定的索引号之间的字符,包头不包尾 */
console.log(str.substring(5,9));
</script>
</body>
</html>