fengchuanyu 4 ヶ月 前
コミット
f9a5d41824

+ 44 - 0
js复习/15_字符串内置方法.html

@@ -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>

+ 26 - 0
js复习/16_转义字符&实体字符.html

@@ -0,0 +1,26 @@
+<!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>
+    <!-- 实体字符 -->
+    <div> hello world!</div>
+    <!-- <div> a<b </div> -->
+        <!-- <div> a &lt; b </div>
+        &yen;1&nbsp;999
+
+        a&#768; -->
+    <script>
+        // 转义字符
+        var a = "hell'o' world";
+        var b = 'hell"o" world!';
+        var c = 'hell\'o\' \"wo\nrld';
+        console.log(c);
+        
+    </script>
+
+</body>
+</html>