• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Functions

One of the strengths of JavaScript is that it provides support for functions, which is uncommon among scripting languages. On the other hand, JavaScript functions are not as fully developed as those found in languages like C and C++. The functionality that JavaScript does provide through its functions is more than enough to make Web pages come alive.

Syntax

The syntax of JavaScript functions is very straightforward. All function declaration must begin with the keyword function followed by the name of the function. The name of the function is the name that will be used to call on the function within code. Parentheses are placed after the function name to hold arguments that are to be passed into the function. If more than one argument is to be passed into the function, use commas to separate the arguments. On the other hand, if no arguments need to be passed into the function, leave the space between the parentheses empty. Finally, curly brackets are used to contain the code related to the function. Curly brackets are not optional, they are required in JavaScript, even if the function is only made up of one line of code.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint