Function 2--JS Study Note 2015-6-30 (71st Day)

Source: Internet
Author: User

Today will be JS Basic Video tutorial Learning a turning point, because I see the eighth chapter, I found a lot of things themselves and can not be timely understanding and grasp, I decided to tamp the foundation, on the one hand through some examples to help consolidate the foundation

(through the online example and the homework left by the teacher), another aspect, I think accept Master and the suggestion of the Netizen, read the first 6 chapters of elevation 3, then go to see the JavaScript DOM programming art. Look forward to your early stride through the basic stage

Learning, Learning JS is a long-term accumulation of the process, I will certainly persist.

Elevation 3:function Type--internal properties of functions:

1, arguments is an object of an array of classes, containing all the parameters in the passed function;

Arguments also has a callee property, which is a pointer to the function that owns the arguments object;

2, this, this applies the environment object to which the function is executed (the wonderful teacher understands that: this is the object that invokes the current function or method )

Instance:

1Window.color = ' Red ';2 varo = {3Color: ' Blue '4 };5 functionSaycolor () {6Alert This. color);7 }8 Saycolor (); Red because here the Saycolor function is defined in the global scope, when the function is called the Window object9O.saycolor = Saycolor;TenO.saycolor ();//Blue O calls the Saycolor function, so this refers to O, which can be understood;

Properties and methods of the function:

Length and prototype (back again)

Length refers to the number of named arguments that the function expects to receive

Each function contains 2 non-inherited methods apply () and call () their purpose is to invoke the function in a particular scope, which is actually equal to setting the value of the This object in the function body.

Each function inherits the toLocaleString () and toString () methods that always return the function's code valueOf () also returns only the function code (the returned format will vary depending on the browser)

Length instance:

function Sayname (name) {  alert (name);} function sum (NUM1, num2) {  return num1 + num2;} function Sayhi () {  alert (' Hi ');  The  popup string must be quoted}alert (Sayname.length); 1alert (sum.length);     2alert (sayhi.length);   0

The real purpose of apply () and call () is to be able to extend the function, the scope of the run;(this piece is temporarily not understood)

Function 2--JS Study Note 2015-6-30 (71st Day)

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.