03 2022 档案
摘要:1. 扩展运算符 应用 1.复制数组 const arr = [1, 3, 5] const arr2 = [2, 4, 6] (1)es5 const res = arr.concat() console.log(res) // [1, 3, 5] const res2 = [...arr] co
阅读全文
摘要:1.使用Object.prototype.toString.call()方法 function dataType(obj) { var toString = Object.prototype.toString; var map = { '[object Boolean]': 'boolean', '
阅读全文
摘要:1. 浅拷贝 当拷贝的是一个基本数据类型时,拷贝的就是数值;而当拷贝的是一个复杂数据类型的时, 拷贝的就是地址,相当于两个复杂数据类型指向同一个地址,其中一个数据发生改变都会改变。 例如: (1)基本数据类型 var num = 100 var num2 = num num2 = 200 conso
阅读全文
摘要:1. includes() 表示是否找到了参数字符串, 返回布尔值。 const str = 'hello world' const res = str.includes('e') // true const res2 = str.includes('a') //false const res3 =
阅读全文
摘要:1.基本用法 1.数组的解构 const [a, b] = [10, 100] //a = 10 //b = 100 注意:因为数组没key,所有解构出来的a, b可以任意取名然后使用 2.对象的结构 const obj = { name: "Roven", age: 30 } const { na
阅读全文
摘要:# 1.不允许重复声明。 (1)var 可以重复声明,覆盖性。 (2)const、let重复声明会报错。 2.var存在变量提升,const、let不存在变量提升。 点击查看代码 (1) console.log(a) var a = 100 --> 打印为undefined (2) console.
阅读全文