上一页 1 ··· 6 7 8 9 10 11 下一页
摘要: Symbol 1.Symbol 的意义 ​ 之前我们的对象属性的数据类型都是字符串,没有其他的了。所以会导致属性名重复,导致属性值被覆盖的情况。比如,你使用了一个他人提供的对象,但又想为这个对象添加新的方法,在添加的操作就很容易覆盖了原有的方法。所以需要一个独一无二的数据类型来完成这个使命。所以Sy 阅读全文
posted @ 2021-09-08 09:59 青柠i 阅读(196) 评论(0) 推荐(0) 编辑
摘要: es6对象解构 1.普通使用解构赋值 let obj = { name: "fct", age: 21 } // 普通使用解构赋值 var { name, age, hobby } = obj; console.log(name, age, hobby); //fct 21 undefined 2. 阅读全文
posted @ 2021-09-05 18:53 青柠i 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 判断数据类型 function judgeType(ele){ let res = typeof ele; if(res "object"){ // 短路表达式,第一个成立则返回第二个的值,第一个不成立,则返回第一个的值 Object.prototype.toString.call(ele) "[o 阅读全文
posted @ 2021-09-04 13:53 青柠i 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 数组去重 let arr = [{ name: "fct" }, { name: "fct" }, 1, 3, 4, 1, 4, 6]; // 1.Set let newArr = Array.from(new Set(arr)); // let newArr = [...new Set(arr)] 阅读全文
posted @ 2021-09-04 12:29 青柠i 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 继承 1.原型链继承: 让子类的原型对象指向父类的实例,当子类的实例找不到对应的方法时,就按原型链往上找。 function Parent(){ this.name = ["原型链继承"]; } // 原型上挂载方法 Parent.prototype.getName = function(){ co 阅读全文
posted @ 2021-09-03 15:12 青柠i 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 1. call,apply,bind的理解 1.1 三者的区别 改变函数执行时的上下文,改变this的指向。 call,apply立刻执行 bind不是立刻执行,而是复制函数更改this //需求 求数组中最大的值 let arr = [2, 12, 4, 6, 8, 10]; console.lo 阅读全文
posted @ 2021-09-03 12:41 青柠i 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 数组扁平化 数组扁平化:将多维数组转换为一维数组 题目1: 将数组[1, [2, [3, [4, 5]]], 6]转换为[1, 2, 3, 4, 5, 6] // 1.1 reduce方法 const arr = [1, [2, [3, [4, 5]]], 6]; let newArrFun = f 阅读全文
posted @ 2021-09-02 12:39 青柠i 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 1.reduce 求数组中数值之和 /** * 1. reduce 求和 */ let arr = [1, 2, 3, 4, 5]; // let sum = arr.reduce(function (pre, cur, index) { // console.log(pre, cur, index 阅读全文
posted @ 2021-09-01 21:13 青柠i 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 全局作用域和函数作用域,基本概念大家应该都知道,这次总结一下深层次的作用域 function fn(a, c) { console.log(a) // function a() { } var a = 123 console.log(a) // 123 console.log(c) // funct 阅读全文
posted @ 2021-09-01 17:30 青柠i 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 隐式转换 1.题目: //1. console.log(1 + "true"); console.log(1 + true); console.log(1 + undefined); console.log(1 + null); //2. console.log("2" > 10); console 阅读全文
posted @ 2021-09-01 17:24 青柠i 阅读(99) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 下一页