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

[js] 第378天 callee和caller的区别和作用是什么? #2304

Open
haizhilin2013 opened this issue Apr 27, 2020 · 1 comment
Open

[js] 第378天 callee和caller的区别和作用是什么? #2304

haizhilin2013 opened this issue Apr 27, 2020 · 1 comment
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第378天 callee和caller的区别和作用是什么?

我也要出题

@haizhilin2013 haizhilin2013 added the js JavaScript label Apr 27, 2020
@chenshiai
Copy link

arguments.callee 指的是当前函数
Function.caller 指的是调用当前函数的函数
举个例子:

function a() {
  console.log(arguments.callee);
  console.log(a.caller); 
}
function b() {
  a();
}
b();
a();

控制台输出:
[Function: a]
[Function: b]
[Function: a]
null

作用:可以用在需要函数自调用,或者调用父函数的场景下

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

No branches or pull requests

2 participants