- 博客(17)
- 资源 (9)
- 收藏
- 关注
原创 JavaScript常见的六种继承方式
面向对象编程很重要的一个方面,就是对象的继承。A 对象通过继承 B 对象,就能直接拥有 B 对象的所有属性和方法。这对于代码的复用是非常有用的。大部分面向对象的编程语言,都是通过“类”(class)实现对象的继承。传统上,JavaScript 语言的继承不通过 class(ES6 引入了class 语法),而是通过“原型对象”(prototype)实现。那么在JS中常见的继承方式有几种呢?方式一、原型链继承//父类型function Animal(name) { this.name
2021-09-26 20:42:54 1890
原创 手写Promise
class MyPromise { constructor(fn) { this.callbacks = []; this.state = "PENDING"; this.value = null; fn(this._resolve.bind(this), this._reject.bind(this)); } then(onFulfilled, onRejected) { // 实现链式调用 re.
2021-09-24 17:30:04 62
原创 手写 bind、apply、call
1、手写callFunction.prototype.myCall = function (context, args) { context = context || window; context.fn = this; let result = context.fn(...args); delete context.fn; return result}2、手写applyFunction.prototype.myApply = function (c
2021-09-24 17:15:49 64
串口监视器
2015-01-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人