Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call,apply,bind #9

Open
aicekiller opened this issue Mar 27, 2018 · 0 comments
Open

call,apply,bind #9

aicekiller opened this issue Mar 27, 2018 · 0 comments

Comments

@aicekiller
Copy link
Owner

aicekiller commented Mar 27, 2018

都属于Function构造函数原型上的方法Function.prototype

用途

call()调用一个函数,其具有一个指定的this值和参数列表。
apply()调用一个函数,其具有一个指定的this值,以及作为一个数组(或类似数组的对象)提供的参数。

var arr = [1,10,2,8];
Math.max.call(Math,...arr);
Math.max.apply(Math,arr);

bind()创建一个新函数,当调用时,将其this关键字设置为提供的值,在调用新函数时,在任何提供之前提供一个给定的参数序列。
callapply都是为了动态改变this,当一个object没有某个方法,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant