The declaration of the JS function.
The format of the declaring function is as follows:
Function name (argument list) {//functions statement; return value;}
See the specific function declaration.
1. Common functions
<script type= "Text/javascript" > function Showhint () { alert ("normal function"); } </script>
2. Functions with Parameters
<script type= "Text/javascript" > function showresult (obj) { //Processing statement return false; return true; } </script>
It is important to note that for the JS function of the control that produces the callback Like button, return false at the end of the function and no callback. If for some simple operation on the page, or just call the background of a method of the JS function, use return FALSE, you can avoid the page frequent refresh.
3. Function of return value
<script type= "Text/javascript" > function Showreturnobject () { Object obj = new Object (); return obj; } </script>
Can return a JS object.
The JS function itself is not much more complicated, but when it comes to writing, it is important to note that a place is the curly brace, which must appear in pairs. Once missing a place, for hundreds or thousands of lines of JS code, troubleshooting is very difficult.
JS simple, easy to use, but also very easy to write errors in grammar, and difficult to find. Presumably most programmers really love and hate it ...
Getting started with javascript: definition of the 006-JS function