JavaScript Functions
JavaScript functions are used to perform operations. We can call JavaScript function many times to reuse the code.
Advantage of JavaScript function
There are mainly two advantages of JavaScript functions.
1) Code reusability: We can call a function several times so it save coding.
2) Less coding: It makes our program compact. We don’t need to write many lines of code each time to perform a common task.
JavaScript Function Syntax
The syntax of declaring function is given below.
function functionName([arg1, arg2, ...argN])
{
//code to be executed
}
<!DOCTYPE>
<html>
<head>
<title>JavaScript</title>
<script>
function hello() {
document.write("Hello Everybody");
}
function yahoo() {
document.write("Yahoo Baba");
}
hello();
document.write("</br>");
yahoo();
document.write("</br>");
hello();
document.write("</br>");
hello();
</script>
</head>
<body>
</body>
</html>
"Empower yourself by creating and utilizing your own resources, rather than relying on others."
Tuesday, May 14, 2024
JavaScript Functions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment