Wednesday 10 May 2017

js variable

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript typeof</h2>
<p>The typeof operator returns the type of a variable or an expression.</p>

<p id="demo"></p>

<script>
var a="hai";
var b=4;
var c;
var d=null;
document.getElementById("demo").innerHTML =
typeof a +'     a=hai'+'<br>'+
typeof d +'     d=null is treated as object'+'<br>'+
typeof b +'    b=4'+'<br>'+ typeof c +'   just var c'+'<br>'+
 typeof true +'    typeof true'+'<br>'+
 typeof [1,2,3,4] +'    typeof [1,2,3,4]  '+'<br>'+
typeof {name:'john', age:34} + '<br>'+
typeof function myFunc(){}+'         typeof function myFunc(){}   '+'<br>'+
(null === undefined) + "<br>" +
(null == undefined);
</script>

</body>
</html>
<!--
10 == Equal x == y
10 === Strict equal x === y
10 != Unequal x != y
10 !== Strict unequal x !== y

 -->

No comments:

Post a Comment