How to create a function in JavaScript?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
How to create a function in JavaScript?
Rating:
Functions can be considered as sub-programs that are defined to perform different actions. Functions can be invoked within another function or invoked by an event handler of an object. They are defined by using the function keyword followed by a set of parentheses. A function cannot be created within another function, but it can be called by another function. In JavaScript, functions are defined to perform different actions such as performing calculations, creating objects, referencing objects, etc.
The syntax for declaring a function is as follows:
{
//statements
}
The syntax for invoking a function is as follows:
Rating:
Was this information helpful?
Other articles
- What is LiveWire?
- Note for creating multiple sets of radio button.
- What is the lastIndexOf() method?
- How is decision-making done in JavaScript?
- What is the with statement?
