![](https://img-blog.csdnimg.cn/07746e5dbf8f46d4b913ade860f10efe.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
JavaScript中API实现
JavaScript中API实现
Vanghua
这个作者很懒,什么都没留下…
展开
-
手写JavaScript面向对象API底层代码实现
注:本篇博客续上一篇“异步编程函数式编程底层代码手写”,因此编号从13开始 13. instanceof操作符的实现 function imitateInstanceof(left, right) { // 开启尾调用优化条件 "use strict"; // 检查右值是否有[Symbol.hasInstance]属性 if (right && !right[Symbol.hasInstance]) throw new TypeError("原创 2022-02-06 22:16:50 · 539 阅读 · 0 评论 -
手写JavaScript函数式编程和异步编程底层代码
1.call实现 Function.prototype.$call = function(context, ...args) { // 调用者检查 if(typeof this !== "function") throw new TypeError("必须使用函数调用$call方法") // 上下文检查 context = context || globalThis context = context instanceof Object ? cont原创 2021-12-16 21:17:24 · 835 阅读 · 0 评论