About the functions () function object of those small 99

Source: Internet
Author: User

Concept: First, the function is a special type of data, the function is also a type of data, in fact, the function is also an object, function object of the built-in constructor is function ();

Several ways to create a function:

Function declaration method:

function sum (A, b) {return a+b; } ;

Function Text Identification method

var sum = function (A, b) {return a+b;} ;

Function Builder method

var sum= new Function (' A ', ' B ', ' return a+b; ');

A function created using the function constructor method, whose arguments and code snippets are passed in as a string, is equivalent to eval (), where the script checks the output as a string;

var xstring = new Function (' A ', ' B ', ' C ', ' return arguments ');

xstring (' Hello ', 2, ' a ');//output An array containing the list of parameters ["Hello", 2, "a"]

<hr style= "font-size:2px;"/>

About the functions () function object of those small 99

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.