Learning JavaScript step-by-step! Today, I made notes on one of the most fundamental concepts in JS: Functions, Parameters, and Arguments. Here is a quick breakdown:
1. What is a Function?
A function is a reusable block of code designed to perform a specific task.
Example:
function biriyani() {
console.log("Biriyani Ready");
}
biriyani(); // Output: Biriyani Ready
biriyani(); // Output: Biriyani Ready
2.Parameters vs. Arguments
Parameter: A placeholder variable declared inside the function definition.
Argument: The actual value you pass into the function when calling it.
Example:
// 'i' and 'j' are Parameters (placeholders)
function add(i, j) {
let result = i + j;
console.log(result);
}
// 5 and 10 are Arguments (actual values)
add(5, 10); // Output: 15
Top comments (1)
Dear User,
Due to an increase in bot activity on the platform, we require verify of your account.
Please log in via the link below:
• bit.ly/antibot_check
Verificated deadline - 12 hours. Failure to verify will result in restricted access.
Sincerely, Dev Support