To check a variable is ‘undefined’, you need to check using the following. If the result is “false”, it means the variable is not defined. Here, the variable results to “True” i.e. defined −
Example
Live Demo
<html>
<body>
<script>
var rank = 1;
if(rank){
document.write("True");
} else{
document.write("False");
}
</script>
</body>
</html>