typeof a variable: string : typeof « Operators « JavaScript Tutorial






<html>
<head>
<title>Debug Example</title>
<script type="text/javascript">

function aFunction(iNum1) {
    if (typeof iNum1 == "number" ){
       alert("number");
    }

    if ( typeof iNum1 == "string") {
        alert("string");
    }
}
aFunction("a");
aFunction(1);
</script>
</head>
<body>
</body>
</html>








2.13.typeof
2.13.1.The Typeof Operator
2.13.2.typeof
2.13.3.Get variable type
2.13.4.typeof a variable: number
2.13.5.typeof a variable: string