From 3a0140e22f7b3754473f7c1d75436791f6e7601c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8A=E7=AB=A5?= <10033735+Harshreich@user.noreply.gitee.com> Date: Mon, 24 Oct 2022 09:40:18 +0000 Subject: [PATCH 1/4] . MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈昊童 <10033735+Harshreich@user.noreply.gitee.com> --- .../\344\275\234\344\270\232/22.10.24.js" | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 "10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" diff --git "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" new file mode 100644 index 0000000..e9bd219 --- /dev/null +++ "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" @@ -0,0 +1,154 @@ +const users = { + Alex: { + email: 'alex@alex.com', + skills: ['HTML', 'CSS', 'JavaScript'], + age: 20, + isLoggedIn: false, + points: 30 + }, + Asab: { + email: 'asab@asab.com', + skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'], + age: 25, + isLoggedIn: false, + points: 50 + }, + Brook: { + email: 'daniel@daniel.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'], + age: 30, + isLoggedIn: true, + points: 50 + }, + Daniel: { + email: 'daniel@alex.com', + skills: ['HTML', 'CSS', 'JavaScript', 'Python'], + age: 20, + isLoggedIn: false, + points: 40 + }, + John: { + email: 'john@john.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'], + age: 20, + isLoggedIn: true, + points: 50 + }, + Thomas: { + email: 'thomas@thomas.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React'], + age: 20, + isLoggedIn: false, + points: 40 + }, + Paul: { + email: 'paul@paul.com', + skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'], + age: 20, + isLoggedIn: false, + points: 40 + } + } +// 1.统计在线人数 + const arr1 =Object.values(users) + var sum=0 + for (let index = 0; index < arr1.length; index++) { + if (arr1[index].isLoggedIn==true) { + sum++ + } + } + console.log(sum); + +// for(let name in users){ +// if (users[name].isLoggedIn==true) { +// sum++ +// } +// } + + sum=0 +// 2.统计分数大于50的人数 +for(let name in users){ + if (users[name].points>50) { + sum++ + } +} +console.log(sum); +// 3.查找会MongoDB的人,并打印其名字 +const arr =Object.keys(users) +for (let index = 0; index < arr1.length; index++) { + var a= arr1[index].skills.indexOf('MongoDB') + if (a!=-1) { + console.log(arr[index]); + } + } +// for(let name in users){ + +// var a= users[name].skills.indexOf('MongoDB') +// if (a!=-1) { +// console.log(name); +// } +// } +// 4.查找同时会:MongoDB, Express,React,和Node 的人,并打印其名字 +for(let name in users){ + + var a= users[name].skills.indexOf('MongoDB') + var b= users[name].skills.indexOf('Express') + var c= users[name].skills.indexOf('React') + var d= users[name].skills.indexOf('Node') + if (a!=-1&&b!=-1&&c!=-1&&d!=-1) { + console.log(name); + } +} +var collection = { + "1275":{ + "album":"依然范特西", + "artist":"周杰伦", + "tracks":[ + "听妈妈的话", + "千里之外" + ] +}, + "2468":{ + "album":"西界", + "artist":"林俊杰", + "tracks":[ + "西界", + "杀手" + ] +}, + "3245":{ + "artist":"许嵩", + "tracks":[ ] + }, + "5439":{ + "album":"遇见" + } +} + +// 1.定义方法更新记录: +// function updateRecords(id,prop,value) +// 要求: +// 1).如果传入的value是一个空值,表示将该属性删除 +// 2).传入的prop如果是tracks,则代表添加,其他是修改 + const arrC = Object.keys(collection) +function updateRecords(id,prop,value){ + + arrC.forEach(num=>{ + if (id==num) { + + if (prop=='tracks') { + + if (value==null) { + delete collection[num].tracks + } + } + } + }) + +} + + +// 3245 tracks '有何不可' +// 3245 tracks '' -->删 +// 5439 artist '孙燕姿' +// 5439 album '逆光' \ No newline at end of file -- Gitee From 0ecc236082c1240c71ce4b5daefa2b2c62cac1af Mon Sep 17 00:00:00 2001 From: Harshreich <773407390@qq.com> Date: Mon, 24 Oct 2022 22:20:14 +0800 Subject: [PATCH 2/4] . --- .../\344\275\234\344\270\232/22.10.24.js" | 26 ++++++++++++++----- .../\344\275\234\344\270\232/Test.html" | 2 +- .../22.10.24\345\257\271\350\261\241.md" | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 "10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" diff --git "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" index e9bd219..5bd7e78 100644 --- "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" +++ "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.24.js" @@ -94,7 +94,7 @@ for(let name in users){ var a= users[name].skills.indexOf('MongoDB') var b= users[name].skills.indexOf('Express') var c= users[name].skills.indexOf('React') - var d= users[name].skills.indexOf('Node') + var d= users[name].skills.indexOf('Node'); if (a!=-1&&b!=-1&&c!=-1&&d!=-1) { console.log(name); } @@ -130,23 +130,37 @@ var collection = { // 要求: // 1).如果传入的value是一个空值,表示将该属性删除 // 2).传入的prop如果是tracks,则代表添加,其他是修改 - const arrC = Object.keys(collection) + const arrC = Object.keys(collection); function updateRecords(id,prop,value){ arrC.forEach(num=>{ if (id==num) { - + console.log(collection[num]); if (prop=='tracks') { - - if (value==null) { - delete collection[num].tracks + + if (value=='') { + collection[num].tracks.splice(0,collection[num].tracks.length); + }else{ + collection[num].tracks.push(value); } + }else{ + collection[num][prop]=value; + // if (prop=='artist') { + // collection[num][prop]=value + // const Change={artist:value} + // collection[num]=Object.assign(Change,collection[num]) + // } } } }) } +updateRecords(3245,'tracks','有何不可') +updateRecords(3245,'tracks','') +updateRecords(5439,'artist','孙燕姿') +updateRecords(5439,'album','逆光') +console.log(collection); // 3245 tracks '有何不可' // 3245 tracks '' -->删 diff --git "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" index efe8e54..1eeab18 100644 --- "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" +++ "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" @@ -5,7 +5,7 @@ Document - + diff --git "a/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" new file mode 100644 index 0000000..1ac8cdc --- /dev/null +++ "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" @@ -0,0 +1 @@ +付费查看 \ No newline at end of file -- Gitee From 0088a1d0433a117c6038ba97ec1588d6ba2c73c1 Mon Sep 17 00:00:00 2001 From: Harshreich <773407390@qq.com> Date: Tue, 25 Oct 2022 21:24:35 +0800 Subject: [PATCH 3/4] . --- .../22.10.24\345\257\271\350\261\241.md" | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git "a/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" index 1ac8cdc..28a05d0 100644 --- "a/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" +++ "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.24\345\257\271\350\261\241.md" @@ -1 +1,35 @@ -付费查看 \ No newline at end of file +### 箭头函数 + +``` +var aa = (形参列表) => {函数体} +//形参或者函数体只有一个和一句时,可以省略括号 +//无参时,括号不可省略 +//无返回值,一般不用箭头函数 +``` + +### + +### 创建对象 + +``` +//字面量表达式创建对象(字面量:描述自己的量) +var obj = { + //属性 + name:{ + Name:'林', + lastName:'林' + }, + age:18 +} +//创建对象 +var obj = new GetName() +``` + +#### 增删改查 + +``` +//增obj.原来obj中没有的属性,相当于将该属性添加到对象obj中 + obj.gender = '男' + console.log(obj); +//删delete一般删之前要对该属性进行判断 +``` \ No newline at end of file -- Gitee From 52a2d38e4ec12bce5b3415bfedca6ffba817ee40 Mon Sep 17 00:00:00 2001 From: Harshreich <773407390@qq.com> Date: Thu, 27 Oct 2022 13:24:52 +0800 Subject: [PATCH 4/4] . --- .../\344\275\234\344\270\232/22.10.26.js" | 24 +++++++++++++++++++ .../\344\275\234\344\270\232/Test.html" | 2 +- ...26\345\214\205\350\243\205\347\261\273.md" | 15 ++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 "10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.26.js" create mode 100644 "10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.26\345\214\205\350\243\205\347\261\273.md" diff --git "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.26.js" "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.26.js" new file mode 100644 index 0000000..bfe589a --- /dev/null +++ "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/22.10.26.js" @@ -0,0 +1,24 @@ +var num ='500050' +const arr = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'] +const arr1 = ['','十', '百', '千', '万', '十', '百', '千', '亿', '十'] +const numarr=num.split('').reverse() +var newNum='' +const strArr=[] + numarr.forEach((m,n)=>{ + strArr.unshift(m==0?arr[m]:arr[m]+arr1[n]) + + }) + console.log(strArr); + for (let m = 0; m < strArr.length; m++) { + for (let n = 0; n < strArr.length; n++) { + if (strArr[n]=='零'&&strArr[m-n]=='零') { + strArr.splice(n,1) + console.log(strArr); + } + if (strArr[strArr.length-1]=='零') { + strArr.pop() + } + } + } + console.log(strArr); + \ No newline at end of file diff --git "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" index 1eeab18..b182ccd 100644 --- "a/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" +++ "b/10\351\231\210\346\230\212\347\253\245/\344\275\234\344\270\232/Test.html" @@ -5,7 +5,7 @@ Document - + diff --git "a/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.26\345\214\205\350\243\205\347\261\273.md" "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.26\345\214\205\350\243\205\347\261\273.md" new file mode 100644 index 0000000..3811412 --- /dev/null +++ "b/10\351\231\210\346\230\212\347\253\245/\347\254\224\350\256\260/22.10.26\345\214\205\350\243\205\347\261\273.md" @@ -0,0 +1,15 @@ +assign:拷贝,浅拷贝(复制的是对象的地址),(手写一个对象的深拷贝)深拷贝(复制的的对象本身) + +1.浅拷贝一个对象 2.合并对象(target,sources....) + +包装类 原始数据类型: number, boolean, string, null, undefined (symbol,bigint) + +包装类只有:number,boolean,string, null,undefined是没有包装类的 + +与其相对应的包装类成员(即构造函数)会在原地,立即创建出相应的对象,然后用当前对象去调用属性或方法 + +同样的包装类,每一次调用,都会产生不同的对象(对象地址的唯一性) + +对象通过+-*/会自动变成原始数据类型 + +string 类有很多方法和length自动转换为new对象再用delect \ No newline at end of file -- Gitee