Page 211 - Web Applications (803) Class 12
P. 211
Inner Functions
JavaScript supports nested functions i.e., function defined inside another function. Only statements in the
outer function can access the inner function. The inner function can make use of the arguments and variables
of the outer function. However, the outer function cannot make use of the inner function’s arguments and
variables.
Example:
<html>
<body>
<h2>JavaScript Inner Function</h2>
<script>
function add() {
let ctr = 10;
function inc() {ctr += 5;}
inc(); //call to inner function
return ctr;
}
document.write(add()); //call to outer function
</script>
</body>
</html>
Output of the preceding program is as follows:
Do you know?
Many programmers hold the opinion that JavaScript is extremely slow and that using it for more code
than is necessary could have a negative impact on performance. It's sort of true. The performance
itself and the project's quality can both be negatively impacted by inept usage of this language.
Predefined Functions
There are a number of built-in functions in JavaScript that, when used, carry out specific tasks. These are as
follows:
Function Name Description
alert(“message”) If you want to make sure that information reaches the user,
an alert box is commonly utilised.
The user must click “OK” in order to continue once an alert
box appears.
Web Scripting—JavaScript 209

