dev-resources.site
for different kinds of informations.
Javascript Functions Quick References
Published at
12/21/2023
Categories
javascript
cheatsheet
Author
Lam
JavaScript Functions Cheat Sheet
Function Declaration
Syntax
function functionName(parameters) {
// Function body
return result;
}
Example
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet('World'));
Function Expression
Syntax
const functionName = function(parameters) {
// Function body
return result;
};
Example
const greet = function(name) {
return `Hello, ${name}!`;
};
console.log(greet('World'));
Arrow Function
Syntax
const functionName = (parameters) => {
// Function body
return result;
};
Example
const greet = (name) => `Hello, ${name}!`;
console.log(greet('World'));
Immediately Invoked Function Expression (IIFE)
Syntax
(function() {
// Function body
})();
Example
(function() {
console.log('IIFE executed');
})();
Function Parameters and Arguments
Example
function addNumbers(a, b) {
return a + b;
}
console.log(addNumbers(5, 10)); // Output: 15
More: Javascript Cheat Sheet
Articles
12 articles in total
Javascript Functions Quick References
currently reading
JavaScript Requests quick reference
read article
PyTorch Quick Ref
read article
How To Install and Use Docker Compose on Ubuntu 20.04
read article
ChatGPT Coding CheatSheets
read article
DB2 Cheat Sheet
read article
LaTeX: Environments 11
read article
Awk: if-else statement
read article
Adobe Lightroom CC: Using help
read article
History in Proto.io
read article
Laravel: Subdirectories
read article
Multi-line string in Swift
read article
Featured ones: