JavaScript learning (4.3): Calling expressions and Object-creation expressions __javascript invocation expressions

Source: Internet
Author: User
4.5 Invocation Expression
The invocation expression of JavaScript is a syntax representation of a function or method called (or executed). It starts with a function expression that refers to the function to invoke. A function expression follows a pair of parentheses, with a comma-separated list of arguments that can have 0 or more arguments.
F (0)//f is a function expression 0 is a parameter expression Math.max (x,y,x)//math.max is a function, X,y,z is a parameter A.sort ()//a.sort is a function without parameters
When evaluating an invocation expression, the function expression is evaluated first, then the argument expression is evaluated, and a set of parameter values is thrown, and if the value of the function expression is not a callable object, a type error exception is raised. The value of the argument is then assigned to the formal parameter at once, which is specified when the function is defined, and then the function body is executed. If the function uses the return statement to give a returned value, then the return value is the value of the entire invocation expression, otherwise the value of the invocation expression is undefined.
Any invocation expression contains a pair of parentheses and an expression preceding the parenthesis, and if the expression is a property access expression, then the call is called a method call. In a method call, when the function body is executed, the object and array that is accessing the subject as a property is the point of this within its calling method.


4.6 Object-Creation expressions
Object creation expression creates an object and invokes a function (constructor) to initialize the properties of the new object. object creation expressions and function invocation expressions are similar, the difference is that the object creation expression is preceded by a new keyword: new object () new Point (1,2) if an object creation expression does not need to pass in any arguments to the constructor, the empty parentheses can be omitted: New O Bject New Date
When you evaluate an object creation expression, JavaScript first creates a new empty object, and then JavaScript invokes a specified function by passing in the specified parameter and using the new object as the value of this. This function can use this to initialize the properties of this newly created object. Functions that are treated as constructors do not return a value, and the newly created and initialized object is the value of the entire object creation expression. If a constructor does return an object value, the object is used as the value of the entire object creation expression, and the newly created object is discarded.

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.