Use function caller property in JavaScript
Description
The following code shows how to use function caller property.
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function outer(){<!-- w ww . j av a 2s. co m-->
inner();
}
function inner(){
document.writeln(inner.caller);
}
outer(); //function outer(){ inner(); }
inner();//null
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Definition
Call a function defined later in JavaScript
Call a function in hyperlink in JavaScript
Call function inside a function in JavaScri...
Call your function in JavaScript
Call your function in body onLoad event in ...
Convert function to string in JavaScript
Create a function in JavaScript
Create a function variable in JavaScript
Create a function with Function constructor...
Use Bind to create a new new function whose...
Use apply function to call a function in Ja...
Use function as variable in JavaScript
Use function.call() to call a function in J...
Use function to calculate average in JavaSc...
Use same name for different functions in Ja...
Use this to reference function context in J...
Use typeof to check function variable in Ja...
Call a function defined later in JavaScript
Call a function in hyperlink in JavaScript
Call function inside a function in JavaScri...
Call your function in JavaScript
Call your function in body onLoad event in ...
Convert function to string in JavaScript
Create a function in JavaScript
Create a function variable in JavaScript
Create a function with Function constructor...
Use Bind to create a new new function whose...
Use apply function to call a function in Ja...
Use function as variable in JavaScript
Use function.call() to call a function in J...
Use function caller property in JavaScript
Use function reference value passing in Jav...Use function to calculate average in JavaSc...
Use same name for different functions in Ja...
Use this to reference function context in J...
Use typeof to check function variable in Ja...