None.js Step Fifth buffer (buffer)

Source: Internet
Author: User

< 26; i++) {    buf[i] = i + 97;}
    • Console.log (buf.tostring (' ASCII '));
    • Console.log (buf.tostring (' ASCII ', 0,5));
    • Console.log (buf.tostring (' UTF8 ', 0,5));
    • Console.log (buf.tostring (Undefined, 0, 5));
Output
    abcdefghijklmnopqrstuvwxyz    abcde    abcde    abcde
ConstBuf= Buffer. from([0x1, 0x2, 0x3, 0x4, 0x5]);ConstJson= JSON.stringify(BUF);//output: {"type": "Buffer", "Data": [1,2,3,4,5]}Console.Log(JSON);ConstCopy= JSON.Parse(JSON,(Key,Value= {    //Say I really don't understand the mechanism in this    //This time if you print separatelyValue&& value.type === ' Buffer '    //Return is actually a false not that we understand a true    //This time the output is correct    returnValue&& value.type === ' Buffer ' ?        Buffer. from(value.Data): Value;    //This time the output is Lin    returnValue&& value.type === ' Buffer ' ?        "Lin"://LinValue;    //This time the output is M    returnValue&& value.type === ' Buffer ' ?        "Lin":"M";   //M    //This time the output is also m    returnValue&& value.type === ' Buffer ' ?        Buffer. from(value.Data) :"M";   //M});//output: <buffer 05>Console.Log(copy);

None.js Step Fifth buffer (buffer)

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.