08 2021 档案

match() 查询字符串
摘要:##match() 用于字符串 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配。 该方法类似 indexOf() 和 lastIndexOf(),但是它返回指定的值,而不是字符串的位 ####运用 题目:查询字符串中出现次数大于 1 次的字符 土方法: functio 阅读全文

posted @ 2021-08-21 00:23 In-6026 阅读(197) 评论(0) 推荐(0)

JS中的亦或运算符 ^ 的一种运用场景——返回数组元素个数为奇数个的元素
摘要:##异或运算符的性质 #####0与1的运算:相同得 0,相异为 1 1 ^ 1 = 0 1 ^ 0 = 1 0 ^ 0 = 1 0 ^ 1 = 0 #####根本逻辑 12 ^ 5 = 9 | 1 | 1 | 0 | 0 | = 12 | | | | | | | | 0 | 1 | 0 | 1 | 阅读全文

posted @ 2021-08-20 00:15 In-6026 阅读(471) 评论(0) 推荐(0)

map() reduce() filter() 与 forEach()
摘要:###1. map() 遍历元素 不改变原数组arr 返回值为数组 let brr = []; let arr = [1, 2, 3] brr = arr.map(function (item, index, array) { return 2 * item; }); console.log(brr 阅读全文

posted @ 2021-08-18 23:39 In-6026 阅读(44) 评论(0) 推荐(0)

最里层返回值为 0,每层返回值加 1 ,最外层的返回值就是回调的总层数
摘要:题目:给定非负整数,直到数小于 10 栗子: per(999) >> 9*9*9=729 >> 7*2*9=126 >> 1*2*6=12 >> 1*2=2(小于 10,结束运算) ==>> 总共运算 4 次 per(123) >> 1*2*3=6(小于 10,结束运算) ==>> 总共运算 1 次 阅读全文

posted @ 2021-08-15 23:47 In-6026 阅读(56) 评论(0) 推荐(0)

任何非负整数(除了 9 的整数倍)模 9 等与该数字的各数位上位数的和
摘要:栗子: 123 % 9 =6= 1 + 2 + 3 题目: 给定非负整数 n。如果 n 不为单数,则对 n 计算 n 的各个数位上位数的和为 res,如果和也不为单数则继续对 res 进行同样的运算。 123 >> 1+2+3=6(单数,结束) 456 >> 4+5+6=15(不为单数,继续) >> 阅读全文

posted @ 2021-08-14 00:57 In-6026 阅读(52) 评论(0) 推荐(0)

ES11—— 全局对象 globalThis
摘要:一个无论在什么环境,始终指向全局的 this 浏览器的全局是 window node.js 的全局是 global #####作用:在任何环境下,都可以操作全局变量 阅读全文

posted @ 2021-08-11 00:10 In-6026 阅读(86) 评论(0) 推荐(0)

大数值整数运算—— BigInt()
摘要:用于 大数值 、 整数 运算 只能和同类型运算 会在计算末尾加上个 n ,但不影响运算,不需要处理 let maxInt = Number.MAX_SAFE_INTEGER; console.log(maxInt); //9007199254740991 console.log(maxInt + 1 阅读全文

posted @ 2021-08-11 00:06 In-6026 阅读(179) 评论(0) 推荐(0)

ES11—— import 动态导入
摘要:btn.onclick = function() { import('./demo01.js').then(module => { console.log(module); }); } 阅读全文

posted @ 2021-08-10 23:55 In-6026 阅读(225) 评论(0) 推荐(0)

ES11——批量处理异步任务 allSettled 与 all
摘要:Promise.allSettled() 不论状态是否为 true 都会继续执行 const p1 = new Promise((resolve, reject) => { setTimeout(() => { resolve("商品-1"); //成功 }, 1000); }); const p2 阅读全文

posted @ 2021-08-10 23:19 In-6026 阅读(152) 评论(0) 推荐(0)

ES11——class类的私有属性
摘要:通过 # 申明 class girl { //共有属性 name; //私有属性 #age; #weight; constructor(name, age, weight) { this.name = name; this.#age = age; this.#weight = weight; } i 阅读全文

posted @ 2021-08-10 22:46 In-6026 阅读(114) 评论(0) 推荐(0)

ES11——数组降维 flat 与数组遍历降维 flatMap
摘要:let arr = [ [1, 2], [3, [4, 5]] ] console.log(arr.flat()); //[ 1, 2, 3, [ 4, 5 ] ] console.log(arr.flatMap(item => item)); //[ 1, 2, 3, [ 4, 5 ] ] con 阅读全文

posted @ 2021-08-10 22:37 In-6026 阅读(81) 评论(0) 推荐(0)

ES11——去除字符串空白 trim
摘要:trimStart 清楚左部空白,trimEnd 清楚右部空白 let str = ' es11-trim '; str.trimStart(); str.trimEnd(); 阅读全文

posted @ 2021-08-10 22:21 In-6026 阅读(191) 评论(0) 推荐(0)

ES10——二维数组转对象 Object.fromEntries(arr)
摘要:let arr = [ ['name', 'LLC'], ['gender', 'meal'] ] let obj = Object.fromEntries(arr); console.log(obj); //{ name: 'LLC', gender: 'meal' } 和 ES8 的 Objec 阅读全文

posted @ 2021-08-10 22:19 In-6026 阅读(95) 评论(0) 推荐(0)

ES9——扩展运算符 ...
摘要:####合并对象属性 ES6的 Object.assign() 也可以达到相似效果 let obj1 = { age: 110, name: "LLC" } let obj2 = { gender: "meal" } let obj3 = { talent: ['eat', 'talk'] } le 阅读全文

posted @ 2021-08-10 22:10 In-6026 阅读(81) 评论(0) 推荐(0)

ES8——对象方法扩展
摘要:属性名与属性值 let stu = { age: 110, name: "LLC", } console.log(Object.keys(stu)); //[ 'age', 'name' ] console.log(Object.values(stu)); //[ 110, 'LLC' ] cons 阅读全文

posted @ 2021-08-10 21:59 In-6026 阅读(48) 评论(0) 推荐(0)

ES8——await 和 async
摘要:####async 用来声明 async 函数 async function demo() {} console.log(demo()); //Promise {<fulfilled>: undefined} 一个promise对象 await 表达式 await 必须放在 async 函数内 le 阅读全文

posted @ 2021-08-10 01:11 In-6026 阅读(64) 评论(0) 推荐(0)

ES7新特新——arr.includes()判断数组中是否存在某个值
摘要:#####在之前用的是indexOf() 存在就返回下标,不存在返回-1 #####arr.includes() 存在返回true,否则false 阅读全文

posted @ 2021-08-10 01:05 In-6026 阅读(209) 评论(0) 推荐(0)

ES6
摘要:##let与var let不可以重复申明变量,但是var可以 let有块级作用域,var没有 { let name = "LLC"; } 在{}外部是拿不到name的 let不存在变量提升 let不影响作用域链 { console.log(sex); //undifined let name = " 阅读全文

posted @ 2021-08-09 22:36 In-6026

this指向
摘要:##在函数调用中(指向window) function demo() { console.log(this); } demo(); //window ##在对象调用函数中(指向调用这个函数的对象) let Obj = { name: "LLC", say: function() { console. 阅读全文

posted @ 2021-08-09 01:57 In-6026 阅读(39) 评论(0) 推荐(0)

用集合+扩展运算符实现数组去重
摘要:let arr = [1, 1, 2, 2, 3, 4, 5]; let res = new Set(arr); console.log(res); //{1, 2, 3, 4, 5} let arr1 = [...res]; console.log(arr1); //[1, 2, 3, 4, 5] 阅读全文

posted @ 2021-08-07 19:11 In-6026

导航