Arrow functions and Buffer objects

Source: Internet
Author: User

One, arrow function

General function 1

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

General function 2

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

Arrow functions

var add = (A, b) = + A + b;

If there is only one return value inside the function, you do not have to write a return, and if you execute more statements inside it, enclose it in {}.

var add = (A, b) = = {    Console.log ("This is the arrow function");     return A + b;} Console.log (Add (10, 11));

Note the point:

    • The arrow function does not have its own this, which is the outer function of this
    • The arrow function cannot be used as a constructor

    • The arguments in the arrow function is the arguments of the outer function. 

Second, the Buffer object

The buffer operation is memory, it is actually to request a piece of memory, used to store data, new Buffer (n) is to request an n bytes of memory.

The requested bytes are printed out and may not be empty, so you can use Buffer.fill (0) to clear the data, which is represented by the 16 binary.

// Strict mode "use strict"new Buffer (5); // Empty Memory buffer.fill (0); console.log (buffer);

You can also write it directly.

New Buffer ("Hello World");

Arrow functions and Buffer objects

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.