JavaScript isNaN() º¯Êý
·µ»Ø JavaScript È«¾Ö¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
isNaN() º¯ÊýÓÃÓÚ¼ì²éÆä²ÎÊýÊÇ·ñÊÇ·ÇÊý×ÖÖµ¡£
Óï·¨
isNaN(x)
²ÎÊýÃèÊö
x
±ØÐè¡£Òª¼ì²âµÄÖµ¡£
·µ»ØÖµ
Èç¹û x ÊÇÌØÊâµÄ·ÇÊý×ÖÖµ NaN£¨»òÕßÄܱ»×ª»»ÎªÕâÑùµÄÖµ£©£¬·µ»ØµÄÖµ¾ÍÊÇ true¡£Èç¹û x ÊÇÆäËûÖµ,Ôò·µ»Ø false¡£
˵Ã÷
isNaN() º¯Êý¿ÉÓÃÓÚÅÐ¶ÏÆä²ÎÊýÊÇ·ñÊÇ NaN£¬¸ÃÖµ±íʾһ¸ö·Ç·¨µÄÊý×Ö£¨±ÈÈç±» 0 ³ýºóµÃµ½µÄ½á¹û£©¡£
Èç¹û°Ñ NaN ÓëÈκÎÖµ£¨°üÀ¨Æä×ÔÉí£©Ïà±ÈµÃµ½µÄ½á¹û¾ùÊÇ false£¬ËùÒÔÒªÅжÏij¸öÖµÊÇ·ñÊÇ NaN£¬²»ÄÜʹÓà == »ò === ÔËËã·û¡£ÕýÒòΪÈç´Ë£¬isNaN() º¯ÊýÊDZØÐèµÄ¡£
ÌáʾºÍ×¢ÊÍ
Ìáʾ£ºisNaN() º¯Êýͨ³£ÓÃÓÚ¼ì²â parseFloat() ºÍ parseInt() µÄ½á¹û£¬ÒÔÅжÏËüÃDZíʾµÄÊÇ·ñÊǺϷ¨µÄÊý×Ö¡£µ±È»Ò²¿ÉÒÔÓà isNaN() º¯ÊýÀ´¼ì²âËãÊý´íÎ󣬱ÈÈçÓà 0 ×÷³ýÊýµÄÇé¿ö¡£
ʵÀý
ÔÚ±¾ÀýÖУ¬ÎÒÃǽ«Ê¹Óà isFinite() ÔÚ¼ì²âÎÞÇîÊý£º
<script type="text/javascript">
document.write(isFinite(123)) //·µ»Ø false
document.write(isFinite(-1.23)) //·µ»Ø false
document.write(isFinite(5-2)) //·µ»Ø false
document.write(isFinite(0)) //·µ»Ø false
document.write(isFinite(0/0)) //·µ»Ø true
document.write(isFinite("Hello")) //·µ»Ø true
document.write(isFinite("2005/12/12")) //·µ»Ø true
document.write(isFinite(true)) //·µ»Ø false
document.write(isFinite(undefined)) //·µ»Ø true
</script>
Ïà¹ØÎĵµ£º
<html>
<head>
<title>Javascript</title>
<script language="Javascript" type="text/javascript">
function callMethod()
{
/*http://localhost/waa/WebService.asmxΪServic ......
1¡¢¶ÔÏóµÄ¼Ì³Ð£¬Ò»°ãµÄ×ö·¨ÊǸ´ÖÆ£ºObject.extend
prototype.jsµÄʵÏÖ·½Ê½ÊÇ£º
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
......
¶þÊ®¡¢Bookmarklet
1¡¢Ê²Ã´ÊÇBookmarklet£¿£¨What's a Bookmarklet?£©
Q£ºÊ²Ã´ÊÇBookmarklet£¿
A£ºBookmarkletÊÇÕû¸ö¶¼±»°üº¬ÔÚ³¬Á´½ÓURLÖеÄһС¶ÎJavaScript³ÌÐò¡££¨JavaScript URL¾ÍÊÇÕâ¸öÑù×Ó£º<a href="javascript:the code goes here">¡££©¶àÊýä¯ÀÀÆ÷ÔÊÐíÓû§Ìí¼ÓÕâЩJavaScript URLÊéÇ©£¬¾ÍÏñÌí¼ÓÆäËû³¬Á´½ ......
Ô´´úÂëÈçÏ£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ÑéÖ¤ÓÊÏ䵨ַºÏ·¨ÐÔ</title>
<sc ......
ÎļþÄÚÈÝÈçÏ£º£¨Á½¸öÎļþglossy.jsºÍglossy.html£©
/********************************** glossy.js ***********************************/
/**
* glossy.js 1.31 (19-Jul-2007)
* (c) by Christian Effenberger
* All Rights Reserved
* Source: glossy.netzgesta.de
* Distrib ......