About arguments and JS Getting Started

Source: Internet
Author: User

Note: JS series of essays written very casually, are their usual learning to some of the knowledge points, very fragmented, basic is to summarize their own learning to write, I believe that after summing up their own will have more harvest

Today to see a Web project, from the JS code to learn a few knowledge points, summarized under:

1.arguments, the Internet to check the use of

The method uses arguments to refer to the parameter set of the method, which can be understood as a global variable, arguments.length is the number of parameters passed in the method, Arguments[n] refers to the n+1 parameter of the method.

One of the points of knowledge is also learned: Arguments.callee ()--the method itself is called, and the code is as follows:

1 //Example method:connecting Eg:testarguments (5) return 5*4*3*2*12         functiontestarguments () {3             if(Arguments.length = = 1 && arguments[0] <= 1) {4                 return1;5}Else {6                 //Arguments.callee: Calling the method itself7                 returnARGUMENTS[0] * Arguments.callee (arguments[0]-1);8             }9}

Types of methods in 2.js: instance methods, class methods, prototype methods, sample code is as follows:

1         //defining the People class2         functionpeople (name) {3             //Name Property4              This. Name =name;5             //instance Method6              This. Show =function () {7Alert ("My name is" + This. Name);8             }9         }Ten  One         //class Method APeople.run =function () { -Alert ("I can run!"); -         } the  -         //Prototyping Methods -People.prototype.ChineseShow =function () { -Alert ("My name is" + This. Name); +         } -  +         varp =NewPeople ("Xiao Ming"); A         //Calling Object Methods at p.show (); -         //Calling class methods - People.run (); -         //invoking the prototype method -P.chineseshow ();

JS Strong is not much to say, also feel good JS is a very cool thing, so began to learn Rhino book, today This essay is open, after the day to learn, write harvest every day, come on!

About arguments and JS Getting Started

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.