Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

input javascript console

const input = prompt("What's your name?"); //optional params
console.log(input); 
Comment

javascript getting input from console

const readline = require("readline");

rl.question("What is your name? ", function (answer) {
  console.log(`Oh, so your name is ${answer}`);
});
Comment

User Input from Javascript Console

const readline = require("readline");
const ac = new AbortController();
const signal = ac.signal;

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.question("What is your name? ", { signal }, (answer) => {
  console.log(`Oh, so your name is ${answer}`);
  console.log("Closing the console");
  process.exit();
});

signal.addEventListener(
  "abort",
  () => {
    console.log("The name question timed out!");
  },
  { once: true }
);

setTimeout(() => {
  ac.abort();
  process.exit();
}, 10000); // 10 seconds
Comment

PREVIOUS NEXT
Code Example
Javascript :: - Root composer.json requires tymon/jwt-auth ^0.5.12 - satisfiable by tymon/jwt-auth[0.5.12]. 
Javascript :: Node Sass version 6.0.0 is incompatible with ^4.0.0 || ^5.0.0 
Javascript :: load js after ajax 
Javascript :: jquery get data from first column of table 
Javascript :: vscode tab size 
Javascript :: React setup for handling UI. 
Javascript :: javascript array key value html select 
Javascript :: js add delay with promises 
Javascript :: matomo error tracking 
Javascript :: how to send post request js fetch 
Javascript :: react native network request failed fetch 
Javascript :: header in axios 
Javascript :: jquery if else on click 
Javascript :: hasOwnProperty with more than one property javascript 
Javascript :: create array initialize size javascript 
Javascript :: js map over object 
Javascript :: discord js sending a message to a specific channel 
Javascript :: do more than one thing at start of or loop javascript 
Javascript :: javascript get diagonals of array 
Javascript :: javascript get clipboard contents 
Javascript :: inline z-index react 
Javascript :: javascript cookies 
Javascript :: javascript find unique values in array 
Javascript :: check if intersectionobserver supported js 
Javascript :: i18n turn off suspense react 
Javascript :: form serialize to json 
Javascript :: Error: Could not symlink include/node/common.gypi /usr/local/include/node is not writable. 
Javascript :: does json only support ascii 
Javascript :: image url to file js 
Javascript :: performance javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =