Defines two functions, PT output expression and its computed result, put output string:
<span id= "DBG" >
<b> Debugging Information:</b>
</span>
<script language= "JavaScript" >
function pt (myexp) {
document.getElementById ("dbg"). innerhtml+= "<br>   ; " +myexp+ " <font color= #0000C6 > "+eval (myexp). toString () +" </font> ";
}
function put (mystr) {
document.getElementById ("dbg"). innerhtml+= "<br> <font color= #0000C6 > "+mystr+" </font>;
}
</script>
Use case:
<script language= "javascript" >
function IsObject (myVar) {
if (MyVar && typeof myvar=== "Object") {return
true;
} else{return
false;
}
var a= "B";
Switch (a) {case
' a ': put ("Switch A");
Case "B": Put ("Switch B");
Case "C": Put ("Switch C");
Default:put ("switch Default");
PT ("typeof/a/");
PT ("typeof null");
PT ("IsObject (/a/)");
PT ("IsObject (null)");
PT ("0.1+0.2");
PT ("isNaN (NaN)");
PT ("typeof/a/");
PT ("1==true");
PT ("1===true");
</script>
The output screenshot is as follows:
How is it, isn't it convenient? To obtain the full source code, please download the attachment and recommend renaming to the *.html file.
This article is from the "idata" blog, please be sure to keep this source http://idata.blog.51cto.com/4581576/1100061