Tech
Function in javascript
In JavaScript, a function is a reusable block of code that performs a task. You define it once and can call it whenever you need it.
1. Basic function
function greet () {
console . log ( " Hello! " );
}
greet ();
Here, greet is the function name, and greet() calls the function.
2. Function with parameters
Parameters let you pass information into a function:
function greet ( name ) {
console . log ( " Hello, " + n...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to