“JavaScript -Konsole eingeben” Code-Antworten

JavaScript -Konsoleneingabe

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

readline.question('Who are you?', name => {
  console.log(`Hey there ${name}!`);
  readline.close();
});
Different Dunlin

JavaScript -Konsole eingeben

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

JavaScript erhalten Eingaben von der Konsole

const readline = require("readline");

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

Benutzereingabe von JavaScript -Konsole

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
Gabriele Orlandi

Ähnliche Antworten wie “JavaScript -Konsole eingeben”

Fragen ähnlich wie “JavaScript -Konsole eingeben”

Weitere verwandte Antworten zu “JavaScript -Konsole eingeben” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen