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 :: react state array 
Javascript :: clear value input jquery 
Javascript :: @tippyjs/react 
Javascript :: ruby hash to json 
Javascript :: set in javascript 
Javascript :: count the number of elements in an array javascript 
Javascript :: supertest multipart/form-data 
Javascript :: filter by keyname javascript 
Javascript :: change root color js 
Javascript :: how to assign value to variable 
Javascript :: percentage formula in javascript 
Javascript :: sort nested data using sort function javascript 
Javascript :: discord client.send_message js 
Javascript :: background image in react from variable 
Javascript :: how to change background color though props 
Javascript :: react-native safeareaview 
Javascript :: split 2 arrays javascript 
Javascript :: how to search for a voice channel within a guild using discord.js 
Javascript :: convert string to unicode javascript 
Javascript :: chart js radar grid color 
Javascript :: axios default baseurl conditional environment 
Javascript :: string concatenation javascript 
Javascript :: string to currency javascript 
Javascript :: jquery check if element is hidden 
Javascript :: javascript async function 
Javascript :: how to add data-toggle and data-target using jquery 
Javascript :: js how to find element using id 
Javascript :: counter in javascript 
Javascript :: get date one week from now javascript 
Javascript :: nodejs delete s3 folder 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =