Professional Documents
Culture Documents
Basic Syntax
return a + b;
};
Shorter
Examples
// Regular function
function sayHello(name) {
The sayHello function is a regular function. It takes a name parameter and returns a greeting string.
// Arrow function
The sayHelloArrow function is an arrow function. It does the same thing as sayHello, but it's written
in a shorter way using the arrow (=>) syntax.
function outerFunction() {
console.log(result1, result2);
outerFunction();
// Regular Function
function squareRegular(x) {
return x * x;
console.log(squareRegular(3)); // Output: 9
// Regular Function
function isPositiveRegular(number) {
// Regular Function
// Regular Function
function greetRegular(name) {
// Regular Function
function factorialRegular(n) {
if (n === 0 || n === 1) {
return 1;
// Regular Function
function capitalizeRegular(str) {