Table of Contents
this apply call bind
译 详解 this https://segmentfault.com/a/1190000002640298#articleHeader0 全局this 函数或方法里的this 原型中的this 对象中的this DOM 事件回调中的this HTML中的this 重写this eval中的this 使用with时的this jQuery中的this
传递 this
Javascript 进阶:Apply, Call 和 Bind 方法详解 https://code.mforever78.com/translation/2015/05/19/understand-javascripts-this-with-clarity-and-master-it/
Javascript裡的this看的是究竟是誰調用該函式,而不是看該函式被定義在哪個物件內
- this指向於調用該函式之物件
2.this指向全域物件(瀏覽器:window物件、node.js:GLOBAL物件)
物件之成員函式內有函式 借用函式
- this指向利用call或apply所指派給this的物件
(A物件.)函式.call(B物件,參數1,參數2,參數3, ......); //函式的this指向B物件(若B物件為null,則指向全域物件) (A物件.)函式.apply(B物件,[參數1,參數2,參數3, ......]); //函式的this指向B物件(若B物件為null,則指向全域物件)
- this指向new所產生之新物件
- callback函式內的this會指向於調用放入該callback的函式之this所指向之物件
為什麼常常別人實作的callback函式可讓this指向於調用放入該callback的函式之this所指向之物件呢?這表示大家實作上會遵守一個規則,會將自己的this傳給callback當作它的this來用!
func(p1, p2) obj.child.method(p1, p2) func.call(context, p1, p2) // 先不讲 apply
this new JS 的 new 到底是干什么的?
__proto__ 對象 constructor 屬性 prototype 對象
解读ECMAScript——执行环境、作用域及闭包
this bind Reactjs Day 1 - 前言與理解 Function.prototype.bind
bower
專案 初始化 bower.json
bower init
安裝 (–save, –save-dev)
bower install jquery --save
bower install --save-dev mocha
npm
專案 初始化 package.json
npm install -y
安裝 (–save, –save-dev)
npm install mongo-express
npm install --save-dev mocha
pycontw
ic tmp
tmp
「每日一题」cookie、session、localStorage分别是什么?有什么作用? https://zhuanlan.zhihu.com/p/22388743?refer=study-fe
「每日一题」简述 Cookie 是什么 https://zhuanlan.zhihu.com/p/22396872?refer=study-fe
「每日一题」JS里基本类型(值)和复杂类型(引用)有什么区别? https://zhuanlan.zhihu.com/p/22400319?refer=study-fe
「每日一题」Promise 是什么? https://zhuanlan.zhihu.com/p/22782675?refer=study-fe
《前端学习指南》文章精选 https://zhuanlan.zhihu.com/p/23991042?refer=study-fe
ES 6 新特性列表