<!
DOCTYPE html>
<html>
<head>
<title>Experiment 4</title>
<style>
body
font-family: Ariel;
margin: 300px;
</style>
</head>
<body>
<div style="background-color:blue; color:white;border-radius:5px;
padding:20px">Javascript Function</div><br><br>
<div onclick="noarg()" style="background-color:lightgrey; cursor:pointer; padding:
3px; height:25px;"><b>Function without Argument</b></div><br><br>
<div onclick="arg('Argument')" style="background-color:lightgrey; cursor: pointer;
padding: 3px; height: 25px;">
<b>Function with Arguments</b>
</div><br><br>
<div onclick="displayReturnValue()"
style="background-color:lightgrey; cursor: pointer; padding: 3px; height:
25px;"><b>Function with a Return
Value</b></div><br><br>
<div onclick="functionObject()" style="background-color:lightgrey; cursor:pointer;
padding: 3px; height: 25px;border-radius:5px;">
<b>JavaScript Function Object</b>
</div><br><br>
<script>
function noarg()
document.write("<strong><u>Function without Argument</u></strong><br><br>Afunction without
arguments in JavaScript is a named unit of code that is created usingthe<strong>function</strong>
keyword, followed by the function's name, an empty pair ofparentheses <strong>()</strong>, and a
pair of curly braces <strong>{}</strong> containing the code to beexecuted. When this type of
function is called, it runs its internal codewithout expecting any values to be passed to it.");
function arg(var1)
document.write("<strong><u>Function with " + var1 + "</u></strong><br><br>A function with
arguments in JavaScript is a named block of code that is created using the <strong>function</strong>
keyword, followed by the function's name, a set of parentheses <strong>()</strong>, and a list of
parameter names separated by commas and and a pair of curly braces <strong>{}</strong>
containing the code to be executed. When this type of function is called, values can be passed as
arguments into the function's parameters, allowing it to work with and manipulate the provided
data.");
function displayReturnValue()
var result = returnval("Return"); document.write(result);
function returnval(var2)
var message = "<strong><u>Function with " + var2 + "Value</u ></strong > <br><br>A function with
a return value in JavaScript is a named block of code that is created using the
<strong>function</strong> keyword, followed by the function's name, a set of parentheses
<strong>()</strong>, optional parameters, and a block of code within curly braces <strong>{
}</strong>. Inside the function, the return statement is used to specify the value that the function
should produce as its output.";
return message;
function functionObject()
var obj = "<strong><u>Javascript Function Object</u></strong><br><br>A
JavaScript function object is a special type of object that holds executable code, making it reusable
and allowing it to be assigned to variables, passed as arguments, returned from functions, and
manipulated like other data values. It combines the behavior of a function <strong>(code
execution)</strong> with the properties and capabilities of an object <strong>(storing data and
having methods)</strong>.";
var output = new Function("obj", "return obj;");
document.write(output(obj));
</script>
</body>
</html>