日期:2014-05-16  浏览次数:20365 次

js的类型都可以考倒你

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
?<head>
? <title> New Document </title>
? <meta name="Generator" content="EditPlus">
? <meta name="Author" content="">
? <meta name="Keywords" content="">
? <meta name="Description" content="">
? <script type="text/javascript">
? alert("typeof(NaN)=? "+typeof(NaN));???
?
alert("typeof(Infinity)=? "+typeof(Infinity));??
?
alert("typeof(null)=? "+typeof(null));???
?
alert("typeof(undefined)=? "+typeof(undefined));???
?
alert("NaN==NaN=? "+(NaN==NaN));???
?
alert("NaN!=NaN=? "+ (NaN!=NaN));???
?
alert("NaN>NaN=? "+ (NaN>NaN));????
?
alert("null==undefined=? "+ (null==undefined));????
?
alert("null>=undefined=? "+ (null>=undefined));????
?
alert("null<=undefined=? "+ (null<=undefined));????
?
alert("null==null=? "+ (null==null));??
?
alert("null!=null=? "+ (null!=null));???
?
alert("null!=NaN=? "+ (null!=NaN));???
?
alert("null==NaN=? "+ (null==NaN));??
?
alert("NaN==undefined=? "+ (NaN==undefined));???
?
alert("parseInt(\"123abc\")=? "+ parseInt("123abc"));??
?
alert("\"123abc\"-0=? "+ ("123abc"-0));???
?
alert("Infinity>10=? "+ (Infinity>10));???
?
alert("Infinity>\"abc\"=? "+ (Infinity>"abc"));???
?
alert("Infinity==NaN=? "+ (Infinity==NaN));??
?
alert("true==1=? "+ (true==1));???
?
alert("new String(\"abc\")==\"abc\"=? "+ (new String("abc")=="abc"));???
?
alert("new String(\"abc\")===\"abc\"=? "+ (new String("abc")==="abc"));???
?
???
function step(a){??
?
?? return function(x){??
? alert("nei bu x = " + x);
????? return x+a++;??
?
?? }??
?
}??
?
var a = step(10);??
?
var b = step(20);??
?
alert("a(10)=? "+ a(10));??
?
alert("b(20)=? "+ b(20));??
?
var a="123abc";??
?
alert("typeof(a++)=? "+ typeof(a++));??
?
alert("a=? "+ a);?

? </script>
?</head>

?<body>
?
?</body>
</html>