Page 162 - DCAP408_WEB_PROGRAMMING
P. 162
Web Programming
Notes var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById(‘txt’).innerHTML=h+”:”+m+”:”+s;
t=setTimeout(‘startTime()’,500);
}
function checkTime(i)
{
if (i<10)
{
i=”0" + i;
}
return i;
}
</script>
</head>
<body onload=”startTime()”>
<div id=”txt”></div>
</body>
</html>
Output
15:50:23
5.7.3 Boolean Object
The Boolean object represents two values: “true” or “false”.
The following code creates a Boolean object called myBoolean:
var myBoolean=new Boolean();
Note: If the Boolean object has no initial value or if it is 0, -0, null, “”, false, undefined, or NaN,
the object is set to false. Otherwise it is true (even with the string “false”)!
All the following lines of code create Boolean objects with an initial value of false:
var myBoolean=new Boolean();
var myBoolean=new Boolean(0);
var myBoolean=new Boolean(null);
var myBoolean=new Boolean(“”);
var myBoolean=new Boolean(false);
var myBoolean=new Boolean(NaN);
156 LOVELY PROFESSIONAL UNIVERSITY