当一艘船沉入海底-js

139 阅读1分钟

数据类型以及检测方式

juejin.cn/post/684490…

this

juejin.cn/post/684490…

juejin.cn/post/684490… 练习1:

function Foo() {
  getName = function () {
    console.log(1);
  };
  return this;
}
Foo.getName = function () {
  console.log(2);
};
Foo.prototype.getName = function () {
  console.log(3);
};
var getName = function () {
  console.log(4);
};
function getName() {
  console.log(5);
}
Foo.getName();
Foo().getName();
getName();
new Foo.getName();
new Foo().getName();
new new Foo().getName();
// 2 1 1 2 3 3

练习2:

function a(xx){
  this.x = xx;
  return this;
};
var x = a(5);
var y = a(6);
console.log(x.x);
console.log(y.x);
// undefined 6

练习3:

var length = 10;
function fn() {
  console.log(this.length);
}
var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
};
obj.method(fn, 1); 
// 10 2

闭包

juejin.cn/post/693746…

原型/原型链

继承

事件循环

www.bilibili.com/video/BV1kf…

垃圾回收机制

juejin.cn/post/698158…

数组方法

遍历对象、数组

防抖节流

事件机制