Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
function test()
{
var number="1234"

if(typeof(number)=="string")
{
alert("string");
}

What I have tried:

function test()
{
var number="1234"

if(typeof(number)=="string")
{
alert("string");
}
if(typeof(number)=="number")
{
alert("number");
}
}
Posted
Updated 6-Dec-17 21:16pm

1 solution

use isNaN()[^] function

JavaScript
var value ='abc';
if( isNaN(value)) {
alert('Not a number')
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900