Monday, April 23, 2012

Javascript Exercise - Comparison: == vs ===


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - Comparison</title>
<script>

function test(){

info = "<p> == vs === </p>"
 + "<p> 1 == '1' " + (1 == '1') + "</p>" 
 + "<p> 1 != '1' " + (1 != '1') + "</p>" 
 + "<p> 1 === '1' " + (1 === '1') + "</p>" 
 + "<p> 1 !== '1' " + (1 !== '1') + "</p>";

document.getElementById("prompt").innerHTML=info;
}

</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - Comparison</h1>
<div id="prompt"></div>
</body>
</html>

No comments:

Post a Comment