Getting started with javascript: definition of the 006-JS function

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.