function Name( parameter1, parameter2, parameter3, ...)
{
}
Html
<html>
<body>
<script>
// declare a function
function CalculateSum(value1, value2)
{
// summarize and return the result
return value1 + value2;
}
// call the function
var value = CalculateSum(10, 20);
// show the result on the screen
alert(value);
// 30
</script>
</body>
</html>
var Variable = function ( parameter1, parameter2, parameter3, ...)
{
}
Html
<html>
<body>
<script>
// declare a function without a name
// Variable CalculateSum refers to a function without a name
var CalculateSum = function (value1, value2)
{
// summarize and return the result
return value1 + value2;
}
// call the function
var value = CalculateSum(10, 20);
// show the result on the screen
alert(value);
// 30
</script>
</body>
</html>