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 的区别是什么,哪个性能更好一些 #23

Open
lovelmh13 opened this issue Feb 3, 2020 · 0 comments
Open

call 和 apply 的区别是什么,哪个性能更好一些 #23

lovelmh13 opened this issue Feb 3, 2020 · 0 comments

Comments

@lovelmh13
Copy link
Owner

lovelmh13 commented Feb 3, 2020

原题

区别

call传递参数,是一个一个传的。

.call(this, 1, 2, 3);

apply传递参数,直接传一个数组。

.apply(this, [1, ,2, 3])

性能的话,貌似call好一些,因为省去了把数组解构的过程。

又看了大家说的,call可以这样:

var a = [1, 2, 3];
fn.call(null, ...a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant