JS Advanced Programming 2nd part of the Knowledge points 4

Source: Internet
Author: User
The parameters of all functions in ECMAScript are passed by value. 5 Basic data types: undfined,null,boolean,number,string.

All parameters in the ECMAScript are passed as values, and arguments cannot be passed by reference. A function declaration takes precedence over a function expression being parsed by the parser, and the function expression must wait until the parser executes to the line of code it is in before it is actually interpreted. Example: Alert (sum (10,10)), function sum (num1,num2) {return num1+num2;} -------------------------------alert (sum (10,10));//Error Var sum=function (num1,num2) {return num1+num2;} The name of the function is just a variable that contains pointers. Each function contains two non-inherited methods: Apply () and call (); the Apply () method accepts two parameters: one is the scope in which the function is run, and the other is the parameter array. Where the second argument can be an instance of an array, or it can be an arguments object. The call () method works the same as the Apply () method, except that the parameters are received differently, and the arguments passed to the function must be enumerated individually for the calling () method: function CallSum1 (num1,num2) {//return Sum.apply (this,arguments);//Incoming Arguments object return Sum.call (THIS,NUM1,NUM2);  The above method is really powerful place to expand the scope of functions on which to run. All objects in the Boolean expression will be converted to true;

JS Advanced Programming 2nd part of the Knowledge points 4

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.