"JavaScript" Code network front-end written test local environment construction

Source: Internet
Author: User

Reference: https://hoofoo.me/article/2017-04-11/%E8%B5%9B%E7%A0%81%E7%BD%91%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AF%95%E6%9C% Ac%e5%9c%b0%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba.html

Implementation of the Print method

This is no difficulty, just console.log change the name of the thing, a line of code can be solved.

var print = Console.log

implementation of Read_line method

As we Node.js all know, it is an asynchronous language, so it is readline also an asynchronous operation, according to the node. JS Chinese documentation, readline this is done:

Const ReadLine = require (' readline '= readline.createinterface ({  Input:process.stdin,  output: Process.stdout}); Rl.question (' What do you think of the node. JS Chinese web? ', (answer) = {  //  to process the answer   console.log (' Thank you for your feedback: ${answer} ');  Rl.close ();});

or it is done in the following way:

Rl.on (' line ', (input) = {  Console.log (' Received: ${input} ');});

installation readline-sync , Node.js environment, I will not introduce a lot of the big boys are very clear. Yes, if it cli is useful to write a tool, but now the needs are different, we need to copy to the answer box can be directly run code, now the artifact should appear.

NPM Install Readline-sync

Despair is still GitHub reliable, only two steps to achieve the read_line method:

var __readline = require (' Readline-sync '})var read_line = __ Readline.prompt

Before writing, copy the following code to the previous

"JavaScript" Code network front-end written test local environment construction

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.