Function
- Function is block of code with set of instruction.
- Once write the instruction and call it many times.
- Function is a resuability code design to perform a specific task.
- Function execute when they are called or invoked.
Syntax for function
function funname()
{
//set of instruction
}
Exaplanation:
- function is a keyword or reserve word.
- funname is a function name.we can give any name but it want to be understandable.
- ()->function bracket.Inside the bracket we give parameters(inputs).
- {}->inside write a set of instruction.
Example:
Without parameter
function sample()
{
console.log("Hello");
}
sample() //function calling statement
with parameter
function add(a,b)
{
console.log(a+b);
}
add(10,20)
Type of :
typeof is operator it return the types of variable.
Example:
console.log(typeof(10))//number10
Top comments (0)