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 :: convert array of javascript into string with comma 
Javascript :: convert a date range into an array of date in js 
Javascript :: angular server start command 
Javascript :: iterate loop over mapping in solidity 
Javascript :: Mongoose and multiple database in single node.js project 
Javascript :: datatables modify rows 
Javascript :: remove duplicates from array javascript 
Javascript :: js convert order to char 
Javascript :: set exit node tor 
Javascript :: heroku buildpacks with react 
Javascript :: javascript datatypes 
Javascript :: parsley validation checkbox 
Javascript :: random color js 
Javascript :: name arrow function 
Javascript :: how to sum variables to an array in javascript 
Javascript :: javascript one line if else 
Javascript :: Javascript Map properties and methods 
Javascript :: how to loop through a map in js 
Javascript :: mongoose get value 
Javascript :: add parameter submit form javascript 
Javascript :: react loop 
Javascript :: how to get data from input field in react js 
Javascript :: jQuery Stop Animations 
Javascript :: new date getday js 
Javascript :: javascript appendchild before 
Javascript :: multipart/form-data ajax jquery 
Javascript :: boucle foreach js 
Javascript :: express prisma 
Javascript :: javascript charcode 
Javascript :: overflowy javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =