diff --git a/readme.md b/readme.md index 5087c572690cff87148be84a5c7d0d394b64018b..1618f8b7462fde3f69baf7d542512d1f5f85ed17 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ -## 24级软件1班 JavaScript笔记 - -上课录屏地址:https://www.alipan.com/s/tnX6ocjnMrQ - +## 24级软件1班 JavaScript笔记 + +上课录屏地址:https://www.alipan.com/s/tnX6ocjnMrQ + "天行健,君子以自强不息。" —— 《周易》 \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251110-\347\254\224\350\256\260+js\345\237\272\347\241\200\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251110-\347\254\224\350\256\260+js\345\237\272\347\241\200\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..2b04eaede8570ab58861fdc41b742fb78a1d7bfd --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251110-\347\254\224\350\256\260+js\345\237\272\347\241\200\347\273\203\344\271\240.md" @@ -0,0 +1,47 @@ +# 笔记 +- 初步了解了js语言 + - ``` + + + ``` + - 效果图: + + ![alt text](./图片/image.png) + + - 书18p 第二题 + - 关键代码 +``` + + + + + Document + + + + + +外部js引用 +alert("http://www.mingrisoft"); +``` +- 效果图: + +![alt text](./图片/image-1.png) \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251112-js\345\207\275\346\225\260\345\237\272\346\234\254\350\257\255\346\263\225+\350\257\276\346\234\254\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251112-js\345\207\275\346\225\260\345\237\272\346\234\254\350\257\255\346\263\225+\350\257\276\346\234\254\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..9cb2012038d27e75c7054d936051cef384bdf169 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251112-js\345\207\275\346\225\260\345\237\272\346\234\254\350\257\255\346\263\225+\350\257\276\346\234\254\347\273\203\344\271\240.md" @@ -0,0 +1,62 @@ +# 笔记 +- 输出 + - 使用 window.alert() 弹出警告框。 + - 使用 document.write() 方法将内容写到 HTML 文档中。 + - 使用 innerHTML 写入到 HTML 元素。 + - 使用 console.log() 写入到浏览器的控制台。 +- 注释 + - 单行注释以 // 开头 + - 多行注释以 /* 开始,以 */ 结尾 + # 练习 +- 25p练习一.练习二 + - 关键代码 + ``` + + + + ``` + - 效果图: + +![alt text](./图片/image-2.png) + +- 28p练习三.练习四 + - 关键代码 + ``` + + + +

个人信息

+ + + + ``` + - 效果图: + +![alt text](./图片/image-3.png) \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251113-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251113-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..8aafd241c9f705f41db14f6c771718d456482deb --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251113-\347\273\203\344\271\240.md" @@ -0,0 +1,93 @@ +## 练习 +- 源代码: +``` + + + + + + Document + + + +
请选择您的出生年月: + + +
+ + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251114-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251114-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..ab2df69e9b742888ce987233b7502bb4a49ecbb9 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251114-\347\273\203\344\271\240.md" @@ -0,0 +1,81 @@ +## 练习 +- 源代码: +``` + + + + + + Document + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251117-\345\207\275\346\225\260\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251117-\345\207\275\346\225\260\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..5b2bcf36d4d0a2066000b4d061e4cbc496904104 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251117-\345\207\275\346\225\260\347\273\203\344\271\240.md" @@ -0,0 +1,24 @@ +## 第二章函数练习题 +- 源代码 +``` + + + + + Document + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251119-\345\207\275\346\225\260\344\272\214\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251119-\345\207\275\346\225\260\344\272\214\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..3a845ce8c2dece60f6e564dc4ee0697639a5a0ba --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251119-\345\207\275\346\225\260\344\272\214\347\273\203\344\271\240.md" @@ -0,0 +1,126 @@ +## 第二章函数练习题 +- 源代码 +``` + + + + + + Document + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251120-\345\257\271\350\261\241\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251120-\345\257\271\350\261\241\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..f5d9cf9ca99c3a1eee18802dec57a72b0e993d8f --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251120-\345\257\271\350\261\241\347\273\203\344\271\240.md" @@ -0,0 +1,39 @@ +## 第三章练习 +- 源代码 +``` + + + + + + Document + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251121-\345\257\271\350\261\241\347\273\203\344\271\240\344\272\214.md" "b/\345\206\257\344\273\201\351\224\220/20251121-\345\257\271\350\261\241\347\273\203\344\271\240\344\272\214.md" new file mode 100644 index 0000000000000000000000000000000000000000..96876bbe742cd1e0b99ab23bb9402ac0711376f8 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251121-\345\257\271\350\261\241\347\273\203\344\271\240\344\272\214.md" @@ -0,0 +1,55 @@ +## 第三章练习 +- 源代码: +``` + + + + + + + Document + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251124-\346\225\260\347\273\204.md" "b/\345\206\257\344\273\201\351\224\220/20251124-\346\225\260\347\273\204.md" new file mode 100644 index 0000000000000000000000000000000000000000..36ea251becc71daed7b827ff4b727fb57f139ed7 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251124-\346\225\260\347\273\204.md" @@ -0,0 +1,28 @@ +## 练习 +- 源代码: +``` + + + + + + Document + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251126-srting.md" "b/\345\206\257\344\273\201\351\224\220/20251126-srting.md" new file mode 100644 index 0000000000000000000000000000000000000000..b331fba820f1df555db64adb4a9b7b0a610e4b55 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251126-srting.md" @@ -0,0 +1,87 @@ +## String 的笔记 +### 一、核心概念梳理 +|比较方式| 关键字 / 方法| 作用| 适用场景| +|---|-----|----|----| +|引用比较| ==| 比较对象在堆中的地址| 判断两个变量是否指向同一对象| +|值比较| equals()| 比较字符串的实际内容| 判断字符串内容是否相同| +|忽略大小写值比较| equalsIgnoreCase()| 内容比较,忽略大小写| 如验证码、用户名比较| +|自然顺序比较| compareTo()| 按字典序比较,返回 int| 排序、大小判断| + +### 二、关键原理补充 +- 字符串常量池: +- 直接赋值的字符串(如 String s1 = "abc")会存入常量池,相同值的字符串复用同一对象; +- new String("abc") 会在堆中创建新对象,即使值相同,地址也不同。 +- equals() 底层: +- String 重写了 Object 的 equals(),先判断地址,再逐字符比较内容。 +- compareTo() 规则: +- 返回 0:内容相同; +- 返回负数:当前字符串 < 参数字符串; +- 返回正数:当前字符串 > 参数字符串; +- (按字符的 Unicode 编码逐位比较,第一个不同字符的差值即为返回值) + +## 练习 +- 源代码: + +``` + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251127.md" "b/\345\206\257\344\273\201\351\224\220/20251127.md" new file mode 100644 index 0000000000000000000000000000000000000000..e80683471a204472825696b4960ba524c0823efd --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251127.md" @@ -0,0 +1,36 @@ +## 练习 +- 源代码: + +``` + + + + + + Document + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251128-\345\274\202\345\270\270\345\244\204\347\220\206.md" "b/\345\206\257\344\273\201\351\224\220/20251128-\345\274\202\345\270\270\345\244\204\347\220\206.md" new file mode 100644 index 0000000000000000000000000000000000000000..a7113e0c58c41b124d714df136dae7a19fd5d5e7 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251128-\345\274\202\345\270\270\345\244\204\347\220\206.md" @@ -0,0 +1,100 @@ +### +- 1. 基础结构:try-catch-finally + - 语法格式 +```js +try { + +} catch (error) { + + console.error("异常触发:", error); +} finally { + +} +``` + +- 核心说明 +- try:包裹 “风险代码”,仅能有一个; +- catch (error):捕获 try 中抛出的异常,error 对象包含 3 个关键属性: +- name:异常类型(如 TypeError); +- message:异常描述信息(如 str.push is not a function); +- stack:异常调用栈(包含文件名、行号,排查核心); +- finally:可选,常用于清理资源(如关闭文件、取消请求),即使 try/catch 中有 return 也会执行。 +示例:处理类型错误 +```js +function formatData(data) { + try { + return data.name || "默认名称"; + } catch (error) { + + if (error instanceof TypeError) { + console.error("数据格式错误:", error.message); + return "默认名称"; } + throw error; + } finally { + console.log("数据格式化流程结束"); + } +} + +formatData(123); + +``` +## 练习 +- 源代码: +``` + + + + + Document + +
+

用户注册

+
+ + +
+
+ + +
+
+ +
+
+ + + + +``` + diff --git "a/\345\206\257\344\273\201\351\224\220/20251201-\344\272\213\344\273\266\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251201-\344\272\213\344\273\266\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..11d9d9e9c7f5acfa68558a56a22ca2390d2bdb84 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251201-\344\272\213\344\273\266\347\273\203\344\271\240.md" @@ -0,0 +1,221 @@ +## 练习 +- 源代码: + +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251203-Document\345\257\271\350\261\241.md" "b/\345\206\257\344\273\201\351\224\220/20251203-Document\345\257\271\350\261\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..67f7941eb7be2d4ab794634fe21dc17dcf358f2d --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251203-Document\345\257\271\350\261\241.md" @@ -0,0 +1,163 @@ +## 练习 +- 源代码: + +``` + + + + + + + + +
+
+ +
+
+

李白 《行路难·其一》

+

金樽清酒斗十千,玉盘珍羞直万钱。

+

停杯投箸不能食,拔剑四顾心茫然。

+

欲渡黄河冰塞川,将登太行雪满山。

+

闲来垂钓碧溪上,忽复乘舟梦日边。

+

行路难,行路难,多歧路,今安在?

+

长风破浪会有时,直挂云帆济沧海。

+ + + + 打开图片对话框 + + + + + + + +
+ +
+ + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251204-\346\226\207\346\241\243\345\257\271\350\261\241\346\250\241\345\236\213.md" "b/\345\206\257\344\273\201\351\224\220/20251204-\346\226\207\346\241\243\345\257\271\350\261\241\346\250\241\345\236\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..dbe789363acc15413b50c9c8c00438fc7a6f6b73 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251204-\346\226\207\346\241\243\345\257\271\350\261\241\346\250\241\345\236\213.md" @@ -0,0 +1,109 @@ +## 练习 +- 源代码: + +``` + + + + + + + + + + + +``` diff --git "a/\345\206\257\344\273\201\351\224\220/20251205-\346\226\207\346\241\243\345\257\271\350\261\241\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251205-\346\226\207\346\241\243\345\257\271\350\261\241\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..a7b2a6ffd06d0f628ee7b0042b3eb8bb3dac0e56 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251205-\346\226\207\346\241\243\345\257\271\350\261\241\347\273\203\344\271\240.md" @@ -0,0 +1,121 @@ +## 练习 +- 源代码: + +``` + + + + + + + + + + + + 年: + 月: + 日: + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251208-windo\345\257\271\350\261\241.md" "b/\345\206\257\344\273\201\351\224\220/20251208-windo\345\257\271\350\261\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..764865f9f803ecc06b5e48bdde961f49daa7a940 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251208-windo\345\257\271\350\261\241.md" @@ -0,0 +1,186 @@ +# 练习 +- 源代码: + +``` + + + + + + Document + + + + + + + + + + + + + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251210-style\345\257\271\350\261\241.md" "b/\345\206\257\344\273\201\351\224\220/20251210-style\345\257\271\350\261\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..0b91bcbca956b670783d1021360fc9eee1c86112 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251210-style\345\257\271\350\261\241.md" @@ -0,0 +1,55 @@ +# 练习 +- 源代码: + +``` + + + + + Document + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251211-Form.md" "b/\345\206\257\344\273\201\351\224\220/20251211-Form.md" new file mode 100644 index 0000000000000000000000000000000000000000..0e631f194e929b910f26fbb07edf1ee2097d4893 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251211-Form.md" @@ -0,0 +1,97 @@ +# 练习 +- 源代码: + +``` + + + + + + Document + + + + + + + + + + + +
+

多行文本框调整

+

+ + +
+ + + +
+

请选择课程(最多选6门)

+ 前端开发
+ Java开发
+ Python开发
+ 数据库原理
+ 计算机网络
+ 操作系统
+ 数据结构
+ 算法设计

+ +

+
+ + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251212-json.md" "b/\345\206\257\344\273\201\351\224\220/20251212-json.md" new file mode 100644 index 0000000000000000000000000000000000000000..fc33951dd83e9deae8d050b0ff47ba4e4ad9f021 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251212-json.md" @@ -0,0 +1,75 @@ +# 练习 +- 源代码 + +``` + +
+

《变形金刚》的主角是谁?

+ 布拉德·皮特
+ 亚当·桑德勒
+ 金·凯瑞
+ 乔夫·丹尼尔斯

+ +

+
+ + + + +
+

兴趣爱好选择

+ 看电影
+ 听音乐
+ 演奏乐器
+ 打篮球
+ 看书
+ 上网

+ + + +
+ + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251215-\347\273\203\344\271\240\351\242\230.md" "b/\345\206\257\344\273\201\351\224\220/20251215-\347\273\203\344\271\240\351\242\230.md" new file mode 100644 index 0000000000000000000000000000000000000000..c1fe3363a8057e361b175b847ec848b050bc64ca --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251215-\347\273\203\344\271\240\351\242\230.md" @@ -0,0 +1,331 @@ +# 练习题数组 + +- 源代码: + +``` + //一数组: + + + // let name="张三" + // let school="某某职业学院" + // console.log(name); + // console.log(school); + + + // let num=123; + // console.log(typeof num); + + // let age=18; + // console.log(age); + // console.log(`修改后:${age+2}`); + + // let name="李四"; + // let age=19; + // let cj=true; + // console.log(`姓名:${name},类型:${typeof name}`); + // console.log(`年龄:${age},类型:${typeof age}`); + // console.log(`及格:${cj},类型:${typeof cj}`); + + // let a = null; + // let b; + // console.log(`变量${a},类型${typeof a}`); + // console.log(`变量${b},类型${typeof b}`); + + + // let name = "张三"; + // let age = 20; + // let score = 85; + // console.log(` ${name}今年${age}岁,考了${score}分,${score >= 60 ? '及格' : '不及格'}`); + + // let a=10; + // let b=3; + // document.write(`加:${a+b},减:${a-b},乘:${a*b},除:${a/b},余:${a%b}`) + + // let str=String('123'); + // let num=Number(456) ; + // console.log(`值${num},类型${typeof num}`); + // console.log(`值${str},类型${typeof str}`); + + // let a=5; + // let b=3; + // console.log(`${a>b},${a===b},${a!==b}`); + + // let x="5"; + // let y=5; + // let z="5"; + // console.log(`${x==y},${x===y},${x==z},${x===z}`); + + + + // let age = 50; + // let hasLicense = false; + // if (age > 18 && age < 60 && hasLicense) { + // alert("可以开车") + // } else { + // alert("年龄不够或者没有驾照") + // } + + + // let num = 3; + // let str = "5" + // let num1 = String("5"); + // let str1 = "10" + // let str2 = "2" + // console.log(String(str1) * String(str2)); + // console.log(str + Number(num)); + + // let sum = 0 + // for (i = 0;i <=100; i++) { + + // sum = i + sum + // } + // console.log(sum); + + + + // let arr = [1, 2, 3, 4, 5, 6, 7, 8] + // let event = []; + // arr.forEach(num => { + // if(num% 2 === 0) { + // event.push(num) + // } + // }) + // console.log(event); + + + + // let n = 40; + // let num = 3 + // let arr = [] + // while (num < n) { + // num += 3; + // arr.push(num); + // } + // console.log(arr); + + + + // let day=3; + // let dayweek=""; + // switch(day){ + // case 1: + // dayweek="星期一"; + // break; + // case 2: + // dayweek="星期二" + // break; + // case 3: + // dayweek="星期三" + // break; + // case 4: + // dayweek="星期四" + // break; + // case 5: + // dayweek="星期五" + // break; + // case 6: + // dayweek="星期六" + // break; + // case 7: + // dayweek="星期日" + // break; + // } + // document.write(`今天是${dayweek},要上班`); + + + // let arr = ["苹果", "香蕉", "橘子"] + // for (arr of arr) { + // console.log(arr); + // } + + + // let prson = { name: "张三", age: 20, city: "北京" } + // for (let x in prson) { + // console.log(`${x}:${prson[x]}`); + + // } + + // let i, j; + // document.write("
")
+        // for (i = 1; i < 20; i++) {
+        //     for (j = 1; j <= i; j++) {
+        //         if(j>1)document.write(" ")
+        //         document.write(j + "x" + i + "=" + j * i)
+        //     }
+        //     document.write("
") + // } + // document.write("
") + + + // let num = Math.floor(Math.random() * 100) + 1 + // let guessNum; + // while (true) { + // const input = prompt("请输入你猜测的数字:"); + // guessNum = Number(input); + // if (guessNum > num) { + // alert("猜的太大了") + // } else if (guessNum < num) { + // alert("太小了") + // } + // else if (guessNum = num) { + // alert("猜对了") + // break; + // } + // } + + // let arr = [1, 2, 3, 4] + // let arr1 = ['a', 'b', 'c', 1]; + // let reslut = fangfa(arr, arr1); + // function fangfa(arr, arr1) { + // return arr.concat(arr1); + // } + // console.log(reslut); + + + // let arr = [1, 2, 3, 4, 5, 6] + // function add(arr1) { + // return arr1.map(num => num * 2) + // } + // console.log(add(arr)); + + + // let num = [1, 2, 3, 4, 5, 6, 7, 8] + // function newhan(arr) { + // return arr.filter(num => num % 2 !== 0) + // } + // console.log(newhan(num)); + + + // let arr=[10,20,30,40,50] + // let sum=arr.reduce((prev,cur)=>prev+cur,0) + // console.log(sum); + + + // let arr=[5,8,1,7,4,9] + // let sum=arr.reduce((prev,cur)=>Math.max(prev,cur)) + // console.log(sum); + + + // let arr = [2, 5, 8, 12, 15, 17] + // let sum = arr.find(function(num){ + // return num>10 + // }) + // console.log(sum); + + + // let arr = [1, 5, 8, -2, 8, -5] + // let sum = arr.findIndex(function (num) { + // return num <0 + // }) + // console.log(sum); + + + // let arr=[1,3,5,7,8] + // let sum=arr.some(function(num){ + // return num%2==0 + // }) + // console.log(sum); + + + // let arr = [1, 2, 3, 4, 5, 6] + // let sum = arr.every(function (num) { + // return num > 0 + // }) + // console.log(sum); + + + // let arr = [40, 100, 1, 5, 25, 10] + // let sum = arr.sort(function (a, b) { + // return a - b; + // }) + // console.log(sum); + + // let students = [ + // { name: "小明", age: 20 }, + // { name: "小红", age: 18 }, + // { name: "小刚", age: 22 } + // ]; + // let sum = students.sort(function (a, b) { + // return a.age - b.age + // }) + // console.log(sum); + + + + // let fruit = ['apple', 'banana', 'orange']; + // let sum = fruit.forEach(function (fruit, suoyin) { + // console.log(`索引${suoyin}:${fruit}`); + // }) + + + + // let arr = [[1, 2], [3, 4], [5, 6]] + // let sum = arr.reduce(function (prev, curr) { + // return prev.concat(curr) + // }) + // console.log(sum); + + + + // let arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'apple'] + // let sum = arr.reduce(function (prev, curr) { + // if (prev[curr]) { + // prev[curr]++; + // } else { + // prev[curr] = 1; + // } + // return prev; + // },[]) + // console.log(sum); + + + // filter(),可以用于筛选,sort()可用于排序, map()可用于提取数据 + // let arr = [ + // { name: "鼠标", price: 29 }, + // { name: "键盘", price: 89 }, + // { name: "显示器", price: 899 }, + // { name: "耳机", price: 199 } + // ] + // let sum = arr.filter(arr => arr.price > 50) + // .sort((a, b) => a.price - b.price)//链式调用多个数组方法 + // .map(arr => arr.name) + // console.log(sum); + + // let arr = [2, 4, 8, 3, 9] + // let sum = arr.map(arr => arr * 2)//链式调用多个数组方法 + // .filter(arr => arr > 10); + // console.log(sum); + + // let arr = [1, 2, 2, 3, 4, 4, 5, 1] + // let sum = arr.reduce(function (prev, curr) { + // if (!prev.includes(curr)) { + // prev.push(curr) + // } + // return prev + // }, []) + // console.log(sum); + + // let arr = [ + // { name: "小明", score: 85 }, + // { name: "小红", score: 92 }, + // { name: "小刚", score: 78 }, + // { name: "小丽", score: 88 } + // ] + // let toatio = arr.reduce((prev, curr) => prev + curr.score, 0) + // let avg=toatio/arr.length + // console.log(avg); + + + // let arr = [ + // { name: "张三", age: 17 }, + // { name: "李四", age: 20 }, + // { name: "王五", age: 25 }, + // { name: "赵六", age: 16 } + // ] + // let age = arr.filter(arr => arr.age >= 18) + // .map(arr => arr.name + (arr.age)) + // console.log(age); + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251217-jQuery\347\254\224\350\256\260.md" "b/\345\206\257\344\273\201\351\224\220/20251217-jQuery\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..6ef03eaf4a92deaff8e1e35ae86849d5a1ea23dc --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251217-jQuery\347\254\224\350\256\260.md" @@ -0,0 +1,37 @@ +### jQuery 基础 + +- 是一个js库,为了方便dom操作 +- 和js的引用一样,建议在body结束标签之前引用 +- 使用`$`来使用jQuery库的能力,`$`符号实际是一个方法,当然方法在js中也是一个对象,所以其也有一些属性可以使用 +- jquery获取到的是jQuery,和原生js拿到的dom对象不同,但它们间可以相互转换 + - let div=$('div')拿到jquery对象 + - div[0]拿到dom对象 + - $(div[0])又可以重新转换为jquery对象 +### jQuery 选择器与操作 +- 基础选择器 + - 标签选择器 + - 类名选择器 + - id选择器 +- 关系选择器 + - 子代选择器 ` ` + - 直接子代选择器 `>` + - 兄弟选择器 `~` + - 相邻兄弟选择器 `+` +- 高级选择器 + - 属性选择器 + - 伪类选择器 + - 伪元素选择器 +### jQuery 事件处理 +- jQuery对象.on('click',function(){}) +- jQuery对象.click(function(){}) +- jQuery对象.trigger('click',function(){}) +- $(function(){}) +### jQuery 动画与效果 +- 基础效果:显示、隐藏 show()、hide()、toggle() +- 进阶效果:淡入、淡出 fadeIn()、fadeOut() +- 高级效果:animate() +### jQuery DOM 操作 +- 新增 append给拿到的元素增加一个下级元素 +- 移除 remove 移除拿到的元素 +- text() 拿到文本内容 ,text('要设置的内容')可以修改纯文本内容 +- html() 拿到包含标签的内容 ,html('要设置的内容')可以修改包含标签的内容 \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251218-JQuery\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251218-JQuery\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..980aa08850c7fee4c4b70ebbcc65a5b30862c575 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251218-JQuery\347\273\203\344\271\240.md" @@ -0,0 +1,121 @@ +# 练习 +- 源代码: + + ``` + + + + + + Document + + + + + + + + + + + + + + + + + +
悬停我
+ + + + + + + + ``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251219-js\347\254\224\350\256\260\346\200\273\347\273\223.md" "b/\345\206\257\344\273\201\351\224\220/20251219-js\347\254\224\350\256\260\346\200\273\347\273\223.md" new file mode 100644 index 0000000000000000000000000000000000000000..b1feea7319638586d7fa0a8d91805448bf35f0f8 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251219-js\347\254\224\350\256\260\346\200\273\347\273\223.md" @@ -0,0 +1,89 @@ +# Javascript技术及应用 + +## Javascript基础 + +### 开发环境与初体验 +- 编辑器 + - 常用编辑器 + - 记事本 + - Sublime Text4 + - vim + - webstorm + - Trae + - HBuilderX + - DreamWeave + - 我们选用的编辑器 + - Visual Studio Code + +### 变量、常量和基础数据类型 +- var let定义变量,请忘记var,后续只使用let +- const定义常量,常量名全大写 +- 数据类型 + - 基础数据类型 + - string + - number + - boolean + - underfined + - null + - 复合数据类型 + - 对象 + - 数组 + - 函数 + +### 运算符和数据类型转换 +- + - * / % +- 逻辑运算 + - null undefined 0 '' 这些字面量参与逻辑运算时,作为false,其余的值作为true + - 短路运算 true || 表达式 false && 表达式 +- 赋值运算 = += -+ ++ --等 +- parseInt parseFloat 乘1变数字 加空字符串变字符串 + +### 流程控制 +- 判断 + - if + - if ... else + - if ... else if() + - if ... else if()... else + - switch +- 循环 + - for + - while + - do...while +- 三元运算 +## 核心数据结构及用法 + +### 数组 +- 改变数组本身的方法 + - sort 排序,接受一个比较器 + - push pop 从尾部添加、删除 + - unshift shift 从头部添加、删除 + - splice 万能方法 删除元素、添加元素、修改元素 + - reverse 倒置 + - fill 填充 +- 不改变数组本身的方法 + - concat 拼接数组 + - slice 截取 + - map 将一个函数用在数组的每一个元素上,并将处理后的结果放入新的数组 + - filter 将一个函数用在数组的每个元素上,如果这个元素运算的结果为true,则将元素放入新的数组,反之不放,最终得到新的数组 + - reduce 将一个函数用在数组的前2个元素上,计算后的结果作为同一个函数第一个参数和数组的第三元素作为第二参数进行运算 + - forEach 遍历 + - find 将一个函数作用在数组的每一个元素上,返回true,则返回这个元素,否则最终返回undefined + - findIndex 将一个函数作用在数组的每一个元素上,返回true,则返回这个元素下标,否则最终返回undefined + - every + - some + - includes + - indexOf + - lastIndexOf + - join +- 高阶函数 + - 一个函数f,接受另外一个函数作为其参数,则称函数f为高阶函数 +### 函数 +- 函数定义 三种定义方式 +- 函数参数 可传可不传,不会因为没有参数而报错 +- 函数返回值 如果没有返回值,则默认返回undefined + +### 对象 +- 包含在一对大括号中的内容 +- 键值对,键也就是属性,值也就属性值 +- 也可以使用类似于数组的形式访问某个值,或者为其添加新的属性 + diff --git "a/\345\206\257\344\273\201\351\224\220/20251222-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251222-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..6945f10160b50dc09f435197c61238989f6a7a0d --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251222-\347\273\203\344\271\240.md" @@ -0,0 +1,212 @@ +## 练习 +- 源代码: + +``` + //二函数: + + // function greet(name) { + // return `你好${name}`; + // } + // let reslut = greet("张三") + // console.log(reslut); + + + + // function max(a, b) { + // if (a > b) { + // return a; + // } + // else { + // return b; + // } + // } + // let num = max(15, 23); + // console.log(num); + + + // function calculateArea(width, heigh = width) { + // return width * heigh; + // } + // let area = calculateArea(5); + // let area1 = calculateArea(5, 10); + // console.log(area); + // console.log(area1); + + + + // let filterEven=(arr)=>arr.filter(num=>num%2==0) + // let input=[1,2,3,4,5,6,7,8] + // console.log(filterEven(input)); + + + + // function processArray(arr, callback) { + // let result = []; + // for (let i = 0; i < arr.length; i++) { + // let processedValue = callback(arr[i], i, arr); + // result.push(processedValue); + // } + // return result; + // } + // let inputArray = [1, 2, 3, 4]; + // let multiplyByTwo = (num) => num * 2; + // let outputArray = processArray(inputArray, multiplyByTwo); + // console.log(outputArray); + + + + // function factorial(n) { + // if (n <= 1) { + // return 1; + // } + // return n * factorial(n - 1); + // } + // console.log(factorial(10)); + + + + // function fibonacci(n) { + // if (n === 0) return 0; + // if (n === 1) return 1; + // return fibonacci(n - 1) + fibonacci(n - 2) + + // } + // console.log(fibonacci(7)); + + + // function getUser({ name, age, city, job }) { + // return { name, age, city }; + // } + // let userInfo = getUser({ + // name: "张三", + // age: 25, + // city: "北京", + // job: "工程师" + // }); + // console.log(userInfo); + + + + //三对象 + // let student = { + // name: "张三", + // age: 20, + // major: "软件技术" + // }; + // console.log(student); + + + + // let person = { + // name: "李四", + // age: "22", + // city: "北京", + // } + // function masaage(person) { + // let name = person.name; + // let age = person.age + // return { name, age } + // } + // console.log(masaage(person) ); + + + + // let product = { + // name: "手机", + // price: 2999, + // stock: 50, + // getInfo() { + // return `${this.name},${this.price},${this.stock}` + // } + // } + // console.log(product.getInfo()); + + + + // let students = [ + // { name: "小明", age: 17 }, + // { name: "小红", age: 19 }, + // { name: "小刚", age: 20 }] + // let sum = students.filter(students=>students.age>=18) + // console.log(sum); + + + // function getUser({ name, age,job }) { + // return { name, age }; + // } + // let userInfo = getUser({ + // name: "张三", + // age: 25, + // job: "工程师" + // }); + // console.log(userInfo); + + + // let Info = { name: "张三", age: 20, city: "北京" } + // let objKeys = Object.keys(Info) + // let objValues = Object.values(Info) + // let objEntries = Object.entries(Info) + // console.log(`keys: ${JSON.stringify(objKeys)}`); + // console.log(`values: ${JSON.stringify(objValues)}`); + // console.log(`entries: ${JSON.stringify(objEntries)}`); + + + // let obj1 = { name: "李四" }; + // let obj2 = { age: 25 }; + // let obj3 = { city: "上海" }; + // let merged = Object.assign({}, obj1, obj2, obj3); + // console.log("Object.assign() 合并结果:", merged); + + + // let person = { + // name: "张三", + // greet() { + // return `你好,我是${this.name}`; + // }, + // }; + // console.log(person.greet()); + + // let p = new Person("李四", 25); + // function Person(name, age) { + // this.age = age; + // this.name = name; + // } + // console.log(p); + + + + // let person = { name: "张三", age: 20 }; + // let hasNameIn = "name" in person; + // let hasAgeOwn = person.hasOwnProperty("age"); + // console.log(`"name" in obj: ${hasNameIn}`); + // console.log(`obj.hasOwnProperty("age"): ${hasAgeOwn}`); + + + + // let key = "score" + // let student = { [key]: 85 } + // console.log(student); + + + + // let list = [ + // { name: "张三", dept: "技术部" }, + // { name: "李四", dept: "销售部" }, + // { name: "王五", dept: "技术部" }, + // { name: "赵六", dept: "人事部" }, + // { name: "孙七", dept: "销售部" } + // ]; + // let group = list.reduce((acc, curr) => { + // let groupKey = curr.dept; + // if (!acc[groupKey]) { + // acc[groupKey] = []; + // } + // acc[groupKey].push(curr); + // return acc; + // }, {}); + // console.log("按部门分组结果:"); + // console.log(JSON.stringify(group)); + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251224-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251224-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..292c789ca3d94d496ac28d6172ac2c8718e1e29d --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251224-\347\273\203\344\271\240.md" @@ -0,0 +1,207 @@ +## 练习 +- 源代码: + +``` + + + + + + Document + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251225-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251225-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..0f53ed92afdef53e3597fb13546a9e491e82b608 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251225-\347\273\203\344\271\240.md" @@ -0,0 +1,79 @@ +## 练习 +- 源代码: + +``` + + + + + + + Document + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/20251226-\347\273\203\344\271\240.md" "b/\345\206\257\344\273\201\351\224\220/20251226-\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..f7148358d9a50287d959eec093378e239ae46bb4 --- /dev/null +++ "b/\345\206\257\344\273\201\351\224\220/20251226-\347\273\203\344\271\240.md" @@ -0,0 +1,88 @@ +## 练习 +- 源代码: + +``` + + + + + + + + + + + + + +
+ + +
+ + +``` \ No newline at end of file diff --git "a/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-1.png" "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-1.png" new file mode 100644 index 0000000000000000000000000000000000000000..be15ecc0ebe19f777844faaa50af31fe92f985b2 Binary files /dev/null and "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-1.png" differ diff --git "a/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-2.png" "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-2.png" new file mode 100644 index 0000000000000000000000000000000000000000..f6b5e7c85945e98f8166bf1b09b17cb293ccf2d7 Binary files /dev/null and "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-2.png" differ diff --git "a/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-3.png" "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-3.png" new file mode 100644 index 0000000000000000000000000000000000000000..fe597fafb84cef6313bacc9ff6598fadd82b431f Binary files /dev/null and "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image-3.png" differ diff --git "a/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image.png" "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image.png" new file mode 100644 index 0000000000000000000000000000000000000000..5f8ca09337ec005809b861fa3563e9b503c0ecb7 Binary files /dev/null and "b/\345\206\257\344\273\201\351\224\220/\345\233\276\347\211\207/image.png" differ