JAVASCRIPT Tutorial
A declaration is a statement that introduces a new entity to a program, such as a variable, a function, or a class. In JavaScript, declarations use the function
keyword followed by the function name, parameters, and code block.
function
keyword declares a new function.{ }
.function function_name(parameters) {
// Code block
}
function addNumbers(num1, num2) {
return num1 + num2;
}
This JavaScript code defines a function called addNumbers
that takes two parameters, num1
and num2
. It returns the sum of the two numbers.