摘要:
一. 扩展运算符 // 1.数组扩展运算符(它好比rest参数的逆运算,将一个数组拆分成以逗号分割的参数序列) let arr = [1, 2] console.log(...arr) // 1, 2 数组的拆分,将一个数组拆分成以逗号分割的参数序列 console.log([0, ...arr, 阅读全文
摘要:
一. this指向 function fun() { this.name = 'Hello' console.log(this.name) } fun() // 空 // 如果一个函数中有this,但是在调用的时候没有被所属对象调用,他会统一指向windows(备注:函数的this不会在定义函数是决 阅读全文
摘要:
一. 原型链继承方式 // 1.原型链继承方式(父类的实例当做子类的原型。如此子类的原型包含父类定义的实例属性,享有父类原型定义的的属性) function SuperType() { // 父类 this.type = 'Somthing Where' } SuperType.prototype. 阅读全文
摘要:
一. 实例、构造函数、原型、和原型链之间的关系 function Person() {} // 构造函数和普通函数的创建方式一样,唯一的区别是构造函数的首写字母需要大写 console.dir(Person.prototype) // 原型(prototype)是一个对象,他和构造函数的关系就是'构 阅读全文