+ 3
How do we take imput from user in java script
tell the statements for all the data types
3 Answers
+ 4
Use prompt("the text","default value")
+ 4
Also you can make an <input> element and use document.getElementById(id of it).value
+ 2
There are actually two types of input data:
1. string - via HTMLElements or prompt window.
You can get any value of every element in the DOM eigther by innerText/innerHTML or from an input element by value.
But even if your input type is "number" the type you get is always a string.
2. Object - in form of Events.
(keyEvent/mouseEvent...)
Events have payload which can be of any JS type. But the payload can not be defined directly by the user.
So the only type of input you can get from the user is: string.