![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
手写编程
手写编程,面试中或者工作中经常会遇到的手写代码
苏坡米
前端攻城狮@_@
展开
-
自己写一个深拷贝
自己写一个深拷贝 let a = { name: 'rober', age: 18, skill: ['3', '4'], obj: { j: 3, k: 4 } } let deepClone = function(o = {}) { if (typeof o !== 'object' || o == null) { // o == null 等价于 o === null || o === undefined return o } let re.原创 2021-07-15 23:25:02 · 73 阅读 · 0 评论 -
手写 bind、apply、call
使用apply Function.prototype.myBind = function () { const t = Array.prototype.shift.call(arguments) const args = arguments const self = this return function () { self.apply(t, args) } } const obj = { x: 111 } const fun = function (v) { cons原创 2021-07-20 10:52:27 · 74 阅读 · 0 评论