What is functions in javascript?

Posted by

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

A function is a set of statements that take inputs, do some specific computation, and produce output. The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different inputs

Syntax

function functionName(Parameter1, Parameter2, ..)
{
    // Function body
}

example

<!DOCTYPE html>
<html>
<head>
		<title> alert in javascript</title>
</head>
<body>
		<script>
		function f1()
		{
		document.write("this is function");
		document.write("<br>");
		document.write("in javascript");
		
		}
		function f2()
		{
		document.write("using multiple ");
		document.write("function");
		}
		
		f1();
		document.write("<br>");
		f2();
		</script>

</body>
</html>

output

this is function
in javascript
using multiple function
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x