JavaScript User-Defined Functions
JavaScript User-Defined Functions A user-defined function saves us from rewriting the same code again and again and helps us to make our application smaller. The given examples will help you to understand how you can put them to work. JavaScript has so many built-in functions, besides that you can make your own as per the need. General structure of the user defined function is: function function_name(par1, par2, …) { //statements } par1, par2 are the name of the parameter, one function could have one, more than one or no parameter. Parameters could be of any data type. Example 1(Simple Function): <html> <head> <title>Simple Function</title> <script type="text/javascript" > function display() { ...