Explain JavaScript function with syntax.

Answer

It is a block of code and is designed to perform a particular tasks. It is executed when "something" invokes it(calls it).

It is defined with the function keywords,paranthesis(),and name.

 

Syntax- function name (parameter1, parameter2, parameter3) {
                         // code to be executed
                }

Why  to use Functions in JavaScript?

You can reuse code: Define the code once, and use it many times.

You can use the same code many times with different arguments, to produce different results.

 

Examples- function toCelsius (fahrenheit) {
                   return (5/9) * (fahrenheit-32);
                 }
document.getElementById("check").innerHTML = toCelsius(77);

All subclass Questions

Ask your interview questions on subclass

Write Your comment or Questions if you want the answers on subclass from subclass Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---