js.l18 code example
Example: js.l18
//
function fun_name(params) { //parameters
operation.............
}
fun_name(params) // call the function.
EXAMPLE:
---------
// ==================
function func(a, b){
console.log(`our comunity`);
let man = 10+11;
console.log(`${man}`)
const arr = [ 14, 25, 31, 400, 'dulon' ];
console.log(arr[4]);
console.log(arr);
console.log(`${arr}`);
let sum = a+b;
return sum;
}
const mn = func(5, 6);
console.log(`sum is: ${mn}`);
//=============
function func(a, b){
let sum = a+b;
return sum;
}
const mn = func(5, 6);
console.log(`sum is: ${mn}`);
---------------------------------
// a function is simply a piece of code that we can reuse
So it's a little bit like a variable but for whole chunks of code.
So remember a variable holds value but a function can hold one or
more complete lines of code.
// So to use the function, we simply write the function name
and this process here of basically using the function is called
invoking the function, running the function
or calling the function.
// thinking write function (calling / running / invoking the function).
// So usually when we write functions we also pass data into a function
and additionally, a function can also return data as well which means
to give us data back.
// functions are actually just values.
So just as a number or a string or a boolean value. So a function
is not a type, okay? It's not like a string or number type but it's
also a value. And so if it's a value, we can store it in a variable.