Fork me on github
摘要: 递归和非递归版本 const arr = [ 123, 2, [ 2,3,4 ,[ 345, 34, [ 34,34,34 ] ] ] ] const flatten = (arr) => { return arr.reduce((acc, val) => Array.isArray(val) ? 阅读全文
posted @ 2023-09-10 21:53 zjy4fun 阅读(1) 评论(0) 推荐(0) 编辑
摘要: https://github.com/zjy4fun/notes/tree/main/demos/js-promise 三个状态,两个回调队列,then 的时候针对不同状态进行处理 const PENDING = 'PENDING'; const FULFILLED = 'FULFILLED'; c 阅读全文
posted @ 2023-09-10 21:27 zjy4fun 阅读(2) 评论(0) 推荐(0) 编辑
摘要: https://github.com/zjy4fun/notes/tree/main/demos/js-instanceof 原型就是一个对象,instanceof 就是检查构造函数的原型是否在对象的原型链上 function myInstanceOf(obj, constructorFn) { c 阅读全文
posted @ 2023-09-10 20:55 zjy4fun 阅读(16) 评论(0) 推荐(0) 编辑
摘要: https://github.com/zjy4fun/notes/tree/main/demos/js-new const myNew = (constructorFn, ...args) => { const obj = Object.create(constructorFn.prototype) 阅读全文
posted @ 2023-09-10 20:41 zjy4fun 阅读(11) 评论(0) 推荐(0) 编辑