Comments (2)
function thunkedYell (text) {
return function thunk () {
console.log(text + '!')
}
}
等同于下面的es6
const thunkedYell = text => () => console.log(text + '!')
// or thunkedYell = text => () => console.log(text + '!')
from til.
call
,apply
,bind
的区别
var a = {
x: "a-x",
getX: function() {
return this.x
}
}
var b = {
x: "b-x"
}
this
区别
// apply
a.getX.apply(b)
// call
a.getX.call(b)
// bind
a.getX.bind(b)()
最后可以发现,都是输出b-x
.
- 他们后面的第一个参数都是绑定上下文的指向
apply
和call
类似,但是apply
后面的第二个参数是数组.call
是一个个的顺序书写.bind'
和apply call
相比.他是新建了一个绑定函数.再去执行.不会立即执行.比如上例就bind
后面还需要()
执行.
from til.
Related Issues (20)
- 缩短过长链接网址 HOT 1
- 惰性函数 HOT 7
- js如何翻转一个字符串&&js如何清除数组
- 没事写了个双向绑定(defineProperty&&Proxy)
- 柯里化函数
- bind, 函数的第二个参数会输出什么? HOT 1
- js的map和forEach到底哪个速度快?
- reduce: 实现一个reduce方法 HOT 2
- js到底是解释型语言还是编译型语言?
- you dont known js - trick && skill
- 如果 $$typeof 是一个 16 进制的数字呢
- 你也是17年才接触前端的吗 HOT 1
- 一些不错的js题 HOT 13
- 一份完整的useEffect指南是翻译的文章么 HOT 1
- [每日见闻-2017-07-26]-ssh相关-配置远程服务器别名 HOT 3
- [每日见闻-2017-07-27]Rails细节的性能对比 HOT 3
- [每日见闻-2017-08-02]sql整理 HOT 1
- [每日见闻-2017-08-08]npm vs yarn HOT 2
- [每日见闻-2017-08-09]ss配置系列 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from til.