0% found this document useful (0 votes)
26 views2 pages

Function Expressions in JS

functions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Function Expressions in JS

functions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function Expression in JavaScript

In JavaScript, a function is a special kind of value. The Function Expression allows


us to create an anonymous function that doesn’t have any function name.

Syntax for Function Declaration:

function functionName(x, y) {
statements...
return (z)
};
Examples
function sum(x, y) {
let z = x + y;
return z;
}
console.log("Addition : " + sum(7, 4));
==========================================================

Syntax for Function Expression (anonymous):

let variableName = function(x, y) {


statements...
return (z)
};

Example:
let sub = function (x, y) {
let z = x - y;
return z;
}
console.log("Subtraction : " + sub(7, 4));

===================================================

Syntax for Arrow Function:

let variableName = (x, y) => { statements... return (z) };

Example:
let divide = (x, y) => {
let z = x / y;
return z;
}

console.log("Division : " + divide(24, 4));

You might also like