js Method Parameter Problem

Source: Internet
Author: User

We all know that Java is a strong type of language, and JS is a weak type of language, in fact, the difference between them is not only this, there are method parameters and call problems, see the following example:

JS: A query () method is defined here

function query () {
var blacklistnumber=$ (' #blacklistNumber '). Val ();
var blacklistname=$ (' #blacklistName '). Val ();
var blacklistsex = $ (' #blacklistSex '). Val ();
Queryobj.blacklistnumber = Blacklistnumber;
Queryobj.blacklistname = Blacklistname;
Queryobj.blacklistsex = Blacklistsex;
var params = json.stringify (queryobj);
var param = encodeuricomponent (params);

Tab.load ({
Pagenumber:1,
Type: ' POST ',
Data: ' param= ' +param+ ' &params= ' +math.random (),
Success:function () {}
});
}

However, when called elsewhere, the query (1)is used, and it is inconceivable that it will enter the query () method as well, because if we call the function as shown in the Java method, it should be the same as the method signature. and method name and method parameters should be consistent, originally, the JS method does not exist method overloads, such as the above example, if followed by a number of methods to define a method named query, such as query (A, B), query (C,D,F), then the default finally self-query (1) You can only invoke query (C,D,F) ...

js Method Parameter Problem

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.