Chapter 315m

जावास्क्रिप्ट फ़ंक्शन

पुन: प्रयोज्य कोड ब्लॉक।

फ़ंक्शन

फ़ंक्शन कोड का पुन: प्रयोज्य ब्लॉक है।

घोषणा

js
function greet(name) {
  return "Hello, " + name;
}
greet("Aarav"); // "Hello, Aarav"

एरो फ़ंक्शन (आधुनिक)

js
const greet = (name) => "Hello, " + name;

Example

javascript
// Functions in JavaScript
function add(a, b) {
  return a + b;
}

const multiply = (a, b) => a * b;

console.log("Sum:", add(5, 3));
console.log("Product:", multiply(5, 3));