diff --git "a/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\214\205\350\243\205\347\261\273.md" "b/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\214\205\350\243\205\347\261\273.md" new file mode 100644 index 0000000000000000000000000000000000000000..599a8f5df769af0b55747baa36737bdd17793a11 --- /dev/null +++ "b/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\214\205\350\243\205\347\261\273.md" @@ -0,0 +1,40 @@ +``` +// 3.要求输入一串低于10位的数字,输出对应的中文大写: +// 例: input: 10001 --> 一万零一 ; input: 10,000,000 --> 一千万 +var gestring=('零','一','二','三','四','五','六','七','八','九','十') +//1-10 +var baistring=('','百','千','万','十','百','千','亿') +var a=prompt('number') +biga(a) +function biga(a) { + var aa=a + if(aa==0){ + print(bigstring[a[0]]) + return + } + while (a!='') { + if(a>0){ + if (a[0]==0) { + if(a.length<=4){ + print (gestring[a[0]]) + }else { + print (gestring[a[0]]) + } + if (a[0]>0||a.length>4) { + print (baistring[a.length-1]) + } + a=a.substring(1); + while (a[0]==0 && a[1]==0){ + a=a.substring(1); + } + } + + } + function print(a) { + document.write(a) + + } + + } +} +``` \ No newline at end of file diff --git "a/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\257\271\350\261\241.md" "b/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\257\271\350\261\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..25220fd6e2a62e44b88d7f1cfc5779e4af54bbb9 --- /dev/null +++ "b/31\345\220\264\346\254\243\347\207\225/\344\275\234\344\270\232/\345\257\271\350\261\241.md" @@ -0,0 +1,170 @@ +``` +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/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-25\345\257\271\350\261\241.md" "b/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-25\345\257\271\350\261\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..97670adb39d3423fe1577f9769824a5a98cf1737 --- /dev/null +++ "b/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-25\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/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-27\345\214\205\350\243\205\347\261\273.md" "b/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-27\345\214\205\350\243\205\347\261\273.md" new file mode 100644 index 0000000000000000000000000000000000000000..4842bced315330e7e07f20fadc38eb27e62ffafa --- /dev/null +++ "b/31\345\220\264\346\254\243\347\207\225/\347\254\224\350\256\260/2022-10-27\345\214\205\350\243\205\347\261\273.md" @@ -0,0 +1,16 @@ +assign:拷贝,浅拷贝(复制的是对象的地址),(手写一个对象的深拷贝)深拷贝(复制的的对象本身) + +1.浅拷贝一个对象 2.合并对象(target,sources....) + +包装类 原始数据类型: number, boolean, string, null, undefined (symbol,bigint) + +包装类只有:number,boolean,string, null,undefined是没有包装类的 + +与其相对应的包装类成员(即构造函数)会在原地,立即创建出相应的对象,然后用当前对象去调用属性或方法 + +同样的包装类,每一次调用,都会产生不同的对象(对象地址的唯一性) + +对象通过+-*/会自动变成原始数据类型 + +string 类有很多方法和length自动转换为new对象再用delect +