khoa-pham-async-await

Các loại Functions


Các loại Functions

1. Declare Function

function add(a, b) {
  return a + b;
}

2. Expressions Function

const luyThua = function (x, a) {
  return x ** a; // x^a
};

console.log(luyThua(2, 3)); // 8 = 2*2*2 = 2^3

3. Arrow Function

const add = (a, b) => a + b;

console.log(add(2, 3)); // 5