JavaScript : function Operator
Description
The function operator defines a function inside an expression.
Version
Implemented in JavaScript 1.5
Syntax
{
statement(s)
}
Parameters
parameters : A list of arguments to the function.
statement(s) : JavaScript statements.
Example :
The following web document demonstrates the use of function operator. It sets x to a function that returns the square of two numbers.
HTML Code
<!doctype html> <head>
<meta charset="utf-8"> <title>JavaScript function operator example.</title> ;meta name="description" content="This document contains an example of JavaScript function operator "/> </head>
<script src="javascript-function-operator-example1.js"></script>
</body>
</html>
JS Code
var a = 12;
var b = 14;
var x = function(a,b)
{
return a*a+2*a*b+b*b;
};
alert("The square of "+a+ " and "+b +" is " +x(a,b));
View the example in the browser
Practice the example above online
JavaScript function operator example.
See also
Conditional Operator
comma
delete
in
instanceof
new
this
typeof
void

