how to get that prompt return string or number ?

作者: dreamfly 分类: 未分类 发布时间: 2014-11-02 13:40
var ask= prompt("Please insert number or string);
alert(typeof ask);

i am using above code but it return me only string not number (if i type Number).
what to do if i use below logic then this will also fail becuase now it will return only number


dialog boxes in JavaScript always return string. Use isNaN() to determine, like this:

var ask= prompt("Please insert number or string");
if (isNaN(ask)){
    alert("You enter a string");
} else {
    alert("You enter a Number");