Quite often, we may come across some situations where we want to execute a block of code at different places. Then we will make use of functions.
The basic syntax of function is shown below.
Try the below example. It defines a function namedsayHello that accepts no parameters −
To call a function somewhere later in the program, one have to write the name of the function as shown in the below example:
So far, we have discussed about functions without parameters. But we can also pass different arguments at the time of calling a function. These passed arguments can be captured inside the function and any operations are performed those arguments. We can also pass multiple arguments to a function separated by comma.
Try the below example. Here we have improvised our say Hello function and it takes two arguments.
For instance, you can pass two arguments in a function and then you can assume the function to return their multiplication in your calling program.
Here is an example which defines a function that takes two arguments and concatenates them before returning the resultant in the calling program.
Java Script Related Tutorials
|Adv Java Tutorial||Core Java Tutorial|
|Java-Springs Tutorial||Java Servlets Tutorial|
|EJB(Enterprise JavaBeans) Tutorial||JavaServer Faces (JSF) Tutorial|
|Java Swing Tutorial||Java Tutorial|
|JavaMail API Tutorial||Java 8 Tutorial|
|Java XML Tutorial||Java Bean Utils Tutorial|
|The Java Debugger (JDB) Tutorial||Java.math Package Tutorial|
Java Script Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||Java-Springs Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JavaServer Faces (JSF) Interview Questions||Java Swing Interview Questions|
|Java 8 Interview Questions||Java XML Interview Questions|
|JavaFX Interview Questions||The Java Debugger (JDB) Interview Questions|
Java Script Related Practice Tests
|Java Script Practice Tests||Adv Java Practice Tests|
|Core Java Practice Tests||Java-Springs Practice Tests|
|Java Servlets Practice Tests||EJB(Enterprise JavaBeans) Practice Tests|
|JavaServer Faces (JSF) Practice Tests||Java 8 Practice Tests|
Java Script Tutorial
Browser And Operating System Detection
All About Events
Advanced Dom Techniques
Forms And Data Integrity
Drag And Drop
Interacting With Plugins
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.