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