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

how to take input from user in javascript console

there's not input console you can get the value from input in html
ex:
<input type="text" id="inp">
<button onclick="show()"></button>

//javascript
var text = document.getElementById("inp")
function show(){
alert(text.value)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: console.log regex 
Javascript :: jquery selected option 
Javascript :: jquery submit refresh page stop 
Javascript :: TypeError: value.toLowerCase is not a function 
Javascript :: add mousedown event listener javascript 
Javascript :: get text of selected option js 
Javascript :: jquery alert on href click 
Javascript :: svelte mount 
Javascript :: kubectl get pod by node 
Javascript :: javascript array foreach example 
Javascript :: how to set content length of an mp3 stream in nodejs 
Javascript :: Material App debug mode 
Javascript :: loopback UserModel.setter.password overwrite 
Javascript :: flutter keep local storage even after is closed 
Javascript :: javascript video after play 
Javascript :: base64 to string and string to base64 javascript decode 
Javascript :: linebreak eslint 
Javascript :: round up javascript 
Javascript :: single quote error in react prettier 
Javascript :: react native gradient touchable feedback 
Javascript :: how to make something spawn randomly p5.js 
Javascript :: Configure morgan so that it also shows the data sent in HTTP POST requests: 
Javascript :: react native navigation back 
Javascript :: Ckeditor get content html 
Javascript :: yarn react-bootstrap 
Javascript :: js remove end comma 
Javascript :: adonisjs sync method 
Javascript :: ClassNotFoundException: com.fasterxml.jackson.core.JsonGenerator 
Javascript :: react native set default ios simulator 
Javascript :: mongo create user 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =