How to check weather a variable in javascript has value or not?

<div id="demo"></div>
var x ="has value"; // first use this in if condition which goes in if condition and gives the output in div with  id=demo 
var y; // then use y in if condition it will goes in else condition and gives the output "undefined variable"
if(x != undefined){
document.getElementById("demo").innerHTML = "variable has some value";
}
else{
document.getElementById("demo").innerHTML = "undefined variable";

}

How to check weather a variable in JavaScript has value or not?expoundsofttechsolution

d