function sample_name(parameters)
{
statements
}
<html>
<head>
<title>Function Example</title>
</head>
<body>
<script type="text/javascript">
function web()
{
alert("www.freetimelearning.com");
//document.write("www.freetimelearning.com")
}
</script>
<input type="button" onclick="web()" value="Click Here"/>
</body>
</html>
<html>
<head>
<title>Function Example</title>
<script type="text/javascript">
function book(name, year)
{
document.write (name + year + " Turorial.");
}
</script>
</head>
<body>
<form>
<input type="button" onclick="book('JavaScript ', 2017)" value="Click Here">
</form>
</body>
</html>
<html>
<head>
<title>Function Argument Objects</title>
</head>
<body>
<script type="text/javascript">
function website(first, mid, last) {
alert("Welcome to " + arguments[0] + "" + arguments[1] + "" + arguments[2]);
}
website("www.", "freetimelearning", ".com");
website("www.", "freetimelearn", ".com");
</script>
</body>
</html>
<html>
<head>
<title>Function with Return Value</title>
</head>
<script type="text/javascript">
function website(){
return "www.freetimelearning.com";
}
</script>
<body>
<script type="text/javascript">
document.write(website());
</script>
</body>
</html>
www.freetimelearning.com
<html>
<head>
<title>Function with Return Value</title>
<script type="text/javascript">
function sample_name(first, mid, last)
{
var website;
website = first + mid + last;
return website;
}
function my_website()
{
var result;
result = sample_name('www.', 'freetimelearning', '.com');
document.write (result );
}
</script>
</head>
<body>
<form>
<input type="button" onclick="my_website()" value="Click Here">
</form>
</body>
</html>