javascriptÊý¾ÝÀàÐÍת»»
parseFloat ת»»³É¸¡µãÊý
parseInt ת»»³ÉÕûÊý.
ÕâÁ½¸öº¯Êý¶¼ÓÐЩÈÝ´íÐÔµÄ,±ÈÈç"123abc"»á±ä³É123.
Èç¹ûÂ¥Ö÷Ï£Íû¸ü׼ȷһЩ,Æäʵ¿ÉÒÔÅжÏÒ»ÏÂ,È»ºóÓÃeval,ÏñÕâÑù
²»¹ýÒ²¿ÉÒÔʹÓÃÕâÑùµÄ·½·¨:
var a = "234" ;
a = a.replace(/(^[\\s]*)|([\\s]*$)/g, "");
if( a !="" && !isNaN( a ) )
{//Èç¹ûÊÇÊý×Ö
a = eval( a )
}
else
{//Èç¹û²»ÊÇÊý×Ö
a = null
}
javascriptÓÐÁ½ÖÖÊý¾ÝÀàÐ͵Äת»»·½·¨£ºÒ»ÖÖÊǽ«Õû¸öÖµ´ÓÒ»ÖÖÀàÐÍת»»ÎªÁíÒ»ÖÖÊý¾ÝÀàÐÍ£¨³Æ×÷»ù±¾Êý¾ÝÀàÐÍת»»£©£¬ÁíÒ»ÖÖ·½·¨ÊÇ´ÓÒ»¸öÖµÖÐÌáÈ¡ÁíÒ»ÖÖÀàÐ͵ÄÖµ£¬²¢Íê³Éת»»¹¤×÷¡£
»ù±¾Êý¾ÝÀàÐÍת»»µÄÈýÖÖ·½·¨£º
1.ת»»Îª×Ö·ûÐÍ£ºString(); Àý£ºString(678)µÄ½á¹ûΪ"678"
2.ת»»ÎªÊýÖµÐÍ£ºNumber(); Àý£ºNumber("678")µÄ½á¹ûΪ678
3.ת»»Îª²¼¶ûÐÍ£ºBoolean(); Àý£ºBoolean("aaa")µÄ½á¹ûΪtrue
´ÓÒ»¸öÖµÖÐÌáÈ¡ÁíÒ»ÖÖÀàÐ͵ÄÖµµÄ·½·¨£º
1.ÌáÈ¡×Ö·û´®ÖеÄÕûÊý£ºparseInt(); Àý£ºparseInt("123zhang")µÄ½á¹ûΪ123
2.ÌáÈ¡×Ö·û´®Öеĸ¡µãÊý£ºparseFloat(); Àý£ºparseFloat("0.55zhang")µÄ½á¹ûΪ0.55
3.Ö´ÐÐÓÃ×Ö·û´®±íʾµÄÒ»¶Îjavascript´úÂ룺eval(); Àý£ºzhang=eval("1+1")µÄ½á¹ûzhang=2
Ïà¹ØÎĵµ£º
ÖÆ×÷ÍøÒ³µÄ¹ý³ÌÖУ¬ÄãÓÐʱºòÐèÒªÖªµÀij¸öÔªËØÔÚÍøÒ³ÉϵÄÈ·ÇÐλÖá£
ÏÂÃæµÄ½Ì³Ì×ܽáÁËJavascriptÔÚÍøÒ³¶¨Î»·½ÃæµÄÏà¹Ø֪ʶ¡£
Ò»¡¢ÍøÒ³µÄ¾ø¶Ô´óСºÍÏà¶Ô´óС
Ê×ÏÈ£¬ÒªÃ÷È·Á½¸ö»ù±¾¸ÅÄî¡£
Ò»ÕÅÍøÒ³µÄÈ«²¿Ãæ»ý£¬¾ÍÊÇËüµÄ¾ø¶Ô´óС¡£Í¨³£Çé¿öÏ£¬ÍøÒ³µÄ¾ø¶Ô´óСÓÉÄÚÈݺÍCSSÑùʽ±í¾ö¶¨¡£
ÍøÒ³µÄÏà¶Ô´óСÔòÊÇÖ¸ÔÚä¯ÀÀÆ÷´°¿ÚÖп ......
keycode 0 =
keycode 1 =
keycode 2 =
keycode 3 =
keycode 4 =
keycode 5 =
keycode 6 =
keycode 7 =
keycode&nb ......
1>zInherit£º
ËüÊÇÒ»¸ö×é¼þ£¬ÓÃÀ´¼Ì³Ð»ùÀàµÄËùÓÐÊôÐԺͷ½·¨¡£¸úÒÔǰ˵µ½µÄÔÐÍÁ´Ä£Ê½·Ç³£ÀàËÆ£¬Ö»²»¹ý±ÈÔÐ͸ü°²È«£¬Ò²ÎÞÐ뿼ÂDzÎÊýÎÊÌâ¡£ÏÂÃæ¿´¿´zInheritµÄÓ÷¨£º
¸Ã×é¼þÖÐÖ»ÓÐÁ½¸ö·½·¨£ºinheritfrom() instanceof()
func ......