Function caller
caller property contains a reference to the function that called this function or null if the function was called from the global scope.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function outer(){
inner();
}
function inner(){
document.writeln(inner.caller);
}
outer(); //function outer(){ inner(); }
inner();//null
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function outer(){
inner();
}
function inner(){
document.writeln(arguments.callee.caller);
}
outer();
inner();
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Essential Types
JavaScript Book
Essential Types
Function:
- The Function Type
- Function Declarations versus Function Expressions
- Functions as Values
- Returning a function from a function
- Function arguments
- this for function context
- Function caller
- Function length property
- Function apply()
- Function.call() method
- Function's bind() method
- Function toLocaleString() and toString()