From 0a4fa3fa8bc8ed054b0ce45ac7d4f0cc3c5767ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=B4=E4=BF=8A=E9=94=8B?= <95995809+zzzzzzz123000@users.noreply.github.com> Date: Tue, 25 Oct 2022 23:24:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\344\275\234\344\270\232/2022.10.24.html" | 75 +++++++++++++++++++ .../\347\254\224\350\256\260/2022.10.24.md" | 47 ++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 "25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" create mode 100644 "25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.24.md" diff --git "a/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" new file mode 100644 index 0000000..142e441 --- /dev/null +++ "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" @@ -0,0 +1,75 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git "a/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.24.md" "b/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.24.md" new file mode 100644 index 0000000..a1df1fa --- /dev/null +++ "b/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.24.md" @@ -0,0 +1,47 @@ +## 1.获取属性的值 + +. + +[ ] + +相同点:获取属性的值 + +不同点: + +1. [ ] 可以获取变量为字符串的内容,. 不可以 + + ```javascript + var str3 = {name:'tuttu',number:'23'} + var key = 'name' + console.log(str3[key]) tuttu + console.log(str3.key) undefined + ``` + +2. [ ] 可以用纯数字作为属性名,.不可以 + + ```javascript + var str3 = {name:'tuttu',3:'23'} + var key = 'name' + console.log(str3[3]) 23 + console.log(str3.3) Uncaught SyntaxError: missing ) after argument list + ``` + +普通常量赋值的时候可以用 . 其他可以用[ ] + +## 2.对象解构 + +```javascript +const hero = { + name:'huhu', + age:15 +} +const{name,age} = hero; +name; +ageg + +// 解构赋值不一定需要与对象的属性匹配。赋值的时候可以忽略某些属性,而如果引用的属性不存在,则为undefined。此时可以在解构的同时定义默认值 + +let {name, job} = person //此时没有job属性 +let {nam, job='student'} //设定默认值 +``` + -- Gitee From dd5aa19b702a26f0cc0672b924a78e6de4e82a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=B4=E4=BF=8A=E9=94=8B?= <95995809+zzzzzzz123000@users.noreply.github.com> Date: Tue, 25 Oct 2022 23:34:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\344\275\234\344\270\232/2022.10.24.html" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" index 142e441..6b3bb23 100644 --- "a/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" +++ "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.24.html" @@ -55,7 +55,7 @@ // console.log(collection[id]); // } // } - value == ''?collection[id][prop] == undefined:((prop == 'tracks')?collection[id][prop].push(value):collection[id][prop] = value) + value == ''? delete collection[id][prop] :((prop == 'tracks')?collection[id][prop].push(value):collection[id][prop] = value) console.log(collection[id]); } -- Gitee From e22094fbbde493e8c9493533c7e6d646f2fdaf72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=B4=E4=BF=8A=E9=94=8B?= <95995809+zzzzzzz123000@users.noreply.github.com> Date: Thu, 27 Oct 2022 12:13:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\344\275\234\344\270\232/2022.10.26.html" | 58 +++++++++++++++++++ .../\347\254\224\350\256\260/2022.10.26.md" | 20 +++++++ 2 files changed, 78 insertions(+) create mode 100644 "25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.26.html" create mode 100644 "25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.26.md" diff --git "a/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.26.html" "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.26.html" new file mode 100644 index 0000000..9cbe497 --- /dev/null +++ "b/25\346\210\264\344\277\212\351\224\213/\344\275\234\344\270\232/2022.10.26.html" @@ -0,0 +1,58 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.26.md" "b/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.26.md" new file mode 100644 index 0000000..d2d1db6 --- /dev/null +++ "b/25\346\210\264\344\277\212\351\224\213/\347\254\224\350\256\260/2022.10.26.md" @@ -0,0 +1,20 @@ +assign 合并对象 + +```javascript +const obj = { a: 1 }; +const copy = Object.assign({}, obj); +console.log(copy); // { a: 1 } +``` + +包装类 :三种包装类 + + **new** **Number**(); **new** **String**(); **new** **Boolean**(); + +当对原始值进行属性赋值时,会将原始值包装成对象并赋值,但无法保存该对象,赋值完成后会立即删除对象的属性。 + +```javascript + var a = 123; + a.len = 3; // new Number(a).len = 3; delete; + console.log(a.len); // undefined +``` + -- Gitee