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 0000000000000000000000000000000000000000..5bd7e78bd8d3484a39b9f5b60daeefd3b95d8831 --- /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,168 @@ +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) { + console.log(collection[num]); + if (prop=='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 '' -->删 +// 5439 artist '孙燕姿' +// 5439 album '逆光' \ 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/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 0000000000000000000000000000000000000000..bfe589ab120e8a2a23e7820bb325f121c44754e4 --- /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 efe8e544fd0c0e4fbb3fa2e58cce83e87ededc98..b182ccd57ebeeead7d2074040627d0e4cb98447a 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 0000000000000000000000000000000000000000..28a05d0965e70d3db45e4f79207b075262bf969a --- /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,35 @@ +### 箭头函数 + +``` +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 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 0000000000000000000000000000000000000000..3811412acb73541cac2d83ad4a57831d4fbc9186 --- /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