Functions of JavaScript (iii)

Source: Internet
Author: User

Functions are also objects, owning properties and methods, just like ordinary objects.
1,length Property

Arguments.lenght indicates the number of arguments passed in.

The length property of the function is read-only and represents the number of formal parameters. Can be expressed in Arguments.callee.length:

function Check (args) {     var actual = args.length;      var expected = args.callee.length;      if (Actual! = expected)         {throw  Error (' expected ${expected}, args got ${actual} ')      function  f (x, Y, z) {     check     (arguments); return x+y+Z;} f (on)

2.call () and apply () methods

Call () and apply () can be seen as a method of an object, where the first argument is the parent object to invoke the function, which is the context in which the function body obtains a reference to it. For example:

F.call (o) f.apply (o)

Object o to Call function f ();

F.call (o,1,2) f.apply (o,[))

Call and apply a similar function, the only difference is the form of incoming arguments, call is a single pass, apply is in the form of an array.

3,bind () method

Functions of JavaScript (iii)

Related Article

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.