Learning outlines for JavaScript

Source: Internet
Author: User

1, the definition of the function of JavaScript species:

@ There are two ways to define a function, one to be anonymous and one to assign to a variable.

@ When you set parameters to a function, you can pass in a number of arguments and then refer to them through arguments within the function, but what is rest ?

2, about the scope of the variable

This means that JavaScript actually has only one global scope. Any variable (the function is also considered a variable), if not found in the current function scope, will continue to look up, and finally, if not found in the global scope, the Referenceerror error is reported.

3. Methods

What is a method in JavaScript? Is there anything you need to be aware of? What is the way of definition? How is the Apply function used?

4. High-order function

The so-called higher order function simply passes a function as a parameter into a function.

f = Math.Abs; function Add (x, Y, f) {    return f (x) + f (y);}

5. Map and reduce

function Pow (x) {    return x * x;} var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9//  [1, 4, 9, +, +, +, +, +, Bayi]

It is more intuitive to write directly with loops.

[X1, x2, X3, x4].reduce (f) = f (f ( f (x1, x2), x3), x4)var arr = [1, 3, 5, 7, 9]; Arr.reduce (function (x, y) {     return//  

Converts a numeric string to a corresponding integer

function String2int (s) {  var arr = S.split (")." Map (function(x) {  return x*1 }  );   return arr.reduce (function(x, y) {  return x*10+y; });}

Learning outlines for JavaScript

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.