随笔分类 -  ES6

摘要:关于拼接字符串 const name = '小明'; const score = 59; let result = ''; if(score > 60){ result = `${name}的考试成绩及格`; }else{ result = `${name}的考试成绩不及格`; } 在${}中可以放 阅读全文
posted @ 2021-10-27 23:29 前端HL 阅读(64) 评论(0) 推荐(0)
摘要:set去重 var demo = new Set([1,1,3,5,4,6]); console.log([...demo]); // [1, 3, 5, 4, 6] 合并两个数组,合并两个对象。 const a = [1,2,3]; const b = [1,5,6]; const c = a.c 阅读全文
posted @ 2021-10-27 22:51 前端HL 阅读(98) 评论(0) 推荐(0)
摘要:1.Array.from方法用于将两类对象转为真正的数组:类似数组的对象(array-like object)和可遍历(iterable)的对象(包括 ES6 新增的数据结构 Set 和 Map)。 下面是一个类似数组的对象,Array.from将它转为真正的数组。 let arrayLike = 阅读全文
posted @ 2021-10-27 22:09 前端HL 阅读(73) 评论(0) 推荐(0)
摘要:数组的成员有时还是数组,Array.prototype.flat()用于将嵌套的数组“拉平”,变成一维的数组。该方法返回一个新数组,对原数据没有影响。 [1, 2, [3, 4]].flat() // [1, 2, 3, 4] 上面代码中,原数组的成员里面有一个数组,flat()方法将子数组的成员取 阅读全文
posted @ 2021-10-26 21:45 前端HL 阅读(354) 评论(0) 推荐(0)
摘要:数组实例的fill() fill方法使用给定值,填充一个数组。 ['a', 'b', 'c'].fill(7) // [7, 7, 7] new Array(3).fill(7) // [7, 7, 7] fill方法还可以接受第二个和第三个参数,用于指定填充的起始位置和结束位置。 ['a', 'b 阅读全文
posted @ 2021-10-25 22:34 前端HL 阅读(157) 评论(0) 推荐(0)
摘要:ES5 与 ES6 遍历数组的不同方法 for ... of循环可以代替数组实例的forEach方法。 const arr = ['red', 'green', 'blue']; arr.forEach(function (element, index) { console.log(element) 阅读全文
posted @ 2021-10-25 21:50 前端HL 阅读(155) 评论(0) 推荐(0)
摘要:es6数组求和: let priceArr=[88,58] let priceArrNew = priceArr.reduce((n,m) => n + m);//求和 console.log(priceArrNew);//146 原链接:https://blog.csdn.net/u0115655 阅读全文
posted @ 2021-09-10 14:43 前端HL 阅读(1851) 评论(0) 推荐(0)
摘要:1.axios请求接口的例子, axios库, axios cdn:https://www.bootcdn.cn/axios/0.11.0/ https://cdn.bootcdn.net/ajax/libs/axios/0.11.0/axios.js是一个远程地址,发起axios库发送请求 取da 阅读全文
posted @ 2021-06-08 12:39 前端HL 阅读(93) 评论(0) 推荐(0)
摘要:5.3.3 String 5.字符串包含方法 ECMAScript6增加了3个用于判断字符串是否包含另一个字符串的方法:startsWith()、endsWith()和includes()。 let message = "foobarbaz"; console.log(message.startsW 阅读全文
posted @ 2021-04-18 11:53 前端HL 阅读(1241) 评论(0) 推荐(0)
摘要:1.class介绍 2.class静态成员 3.class的类继承 阅读全文
posted @ 2021-04-01 12:30 前端HL 阅读(143) 评论(0) 推荐(0)
摘要:https://es6.ruanyifeng.com/?search=set&x=0&y=0#docs/set-map#Map 阅读全文
posted @ 2021-03-31 12:45 前端HL 阅读(75) 评论(0) 推荐(0)
摘要:https://es6.ruanyifeng.com/?search=set&x=0&y=0#docs/set-map ES6 提供了新的数据结构 Set。它类似于数组,但是成员的值都是唯一的,没有重复的值。 1.数组去重 2.交集 简写: 3.合并 4.差值 阅读全文
posted @ 2021-03-31 12:27 前端HL 阅读(55) 评论(0) 推荐(0)
摘要:es5回调地狱: es6回调地狱的解决方法: 阅读全文
posted @ 2021-03-27 13:09 前端HL 阅读(149) 评论(0) 推荐(0)
摘要:ES6扩展运算符[...] 阅读全文
posted @ 2021-03-26 12:17 前端HL 阅读(59) 评论(0) 推荐(0)