摘要: 通过JSON拷贝 json数据格式 json全称:JavaScript对象表示法 [ { "name": "小明", "age": 2 },{ "name": "小刚", "age": 3 } ] jsons数据转换 let str = JSON.stringify(obj) // 将对象转换成js 阅读全文
posted @ 2021-07-26 22:27 `Duet` 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 深拷贝 递归的理解 递归:自己调用自己 // 计算累加 function fun(n){ if (n 1){ return 1 } else { return n + fun(n - 1) } } let res = fun(3) console.log(res) // 6 利用递归实现深度克隆 / 阅读全文
posted @ 2021-07-26 22:17 `Duet` 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 浅拷贝 首先看一个vue的例子 <script src="https://cdn.jsdelivr.net/npm/vue@2"></script> <div id="app"> <form @submit.prevent="insert"> <input type="text" v-model=" 阅读全文
posted @ 2021-07-26 22:00 `Duet` 阅读(55) 评论(0) 推荐(0) 编辑
摘要: js内存结构 基本概念 分类: 原始类型(值类型、基本类型):Number、String、Boolean、null、undefined 引用类型:Object // 原始数据类型 let str1 = "hello"; let str2 = str1; // str2 : hello str1 = 阅读全文
posted @ 2021-07-26 20:39 `Duet` 阅读(49) 评论(0) 推荐(0) 编辑
摘要: call、apply、bind call是一个方法,是函数的方法 function fun(){ console.log("hello world") } call可以调用函数 fun.call() // hello world call可以改变函数中this的指向 function fun(){ 阅读全文
posted @ 2021-07-26 20:32 `Duet` 阅读(38) 评论(0) 推荐(0) 编辑