|
@@ -0,0 +1,44 @@
|
|
|
+<!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>
|
|
|
+ var str = "abcdefg";
|
|
|
+ // console.log(str[2]);
|
|
|
+ // chartAt()方法 返回指定位置的字符
|
|
|
+ // console.log(str.charAt(2));
|
|
|
+ // indexOf()方法 返回指定元素在字符串中首次出现的位置 如果没有找到返回-1
|
|
|
+ // console.log(str.indexOf("x"));
|
|
|
+ // includes()方法 判断字符串中是否包含指定元素 返回布尔值
|
|
|
+ // console.log(str.includes("e"));
|
|
|
+
|
|
|
+ // slice()方法 截取字符串 返回截取的字符串
|
|
|
+ // console.log(str.slice(2,5));
|
|
|
+
|
|
|
+ // var str = "2025-1-8";
|
|
|
+ // var str = "helloworld";
|
|
|
+ // split()方法 将字符串分割成数组
|
|
|
+ // console.log(str.split(""));
|
|
|
+
|
|
|
+ // var str = "abcdefg";
|
|
|
+ // console.log(str.substr(2,3));
|
|
|
+ // console.log(str.substring(2,5));
|
|
|
+
|
|
|
+ // var str = " username ";
|
|
|
+ // console.log(str);
|
|
|
+ // trim()方法 去除字符串两端的空格
|
|
|
+ // console.log(str.trim());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|