Javascript obtains the number of function parameters and the number of javascript parameters.

Source: Internet
Author: User

Javascript obtains the number of function parameters and the number of javascript parameters.

/*** Get the number of Function parameters * @ param {function} func [Function to be retrieved] * @ return {*} [array of parameters or undefind] */function getFuncParameters (func) {if (typeof func = 'function') {var mathes =/[^ (] + \ ([^)] *)? \)/Gm.exe c (Function. prototype. toString. call (func); if (mathes [1]) {var args = mathes [1]. replace (/[^, \ w] */g ,''). split (','); return args ;}}}

Javascript defines a function. How can I obtain a parameter triggered by this function?

The Code defines a "class", so you can save the tid value in the data member this. _ tid in the doubleclick method:
This. _ tid = tid;
Then, you can use this. _ tid directly in the cancle method. You do not need to input tid from the function call.

Javascript obtains the parameters or variables of another function from one function on this page.

Var s = 0;
Function sex (x ){
X = 1? S = "male": s = "female ";
}
Function user (){
Alert (s); // you can use the sex function to determine whether the name is male or female ";
}

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.