JavaScriptµÄÀàÐÍת»»(×Ö·ûתÊý×Ö£¬Êý×Öת×Ö·û)
ÔÚJavaÖУ¬»ù±¾ÀàÐÍÖ®¼äµÄÇ¿ÖÆת»»Ò²²»ÊÇÕâÑùµÄ£¬±ÈÈ磬ÕûÊýҪת»»³É×Ö·û´®£¬±ØÐëʹÓÃInteger.toString()¾²Ì¬·½·¨»òÕßString.valueOf()¾²Ì¬·½·¨£¬°Ñ×Ö·û´®×ª»»ÎªÕûÊý£¬±ØÐëʹÓÃInteger.valueOf()¡£
¿É¼û£¬²»ÄÜ°ÑJavaScriptÖеÄÀàÐÍת»»¿´×÷Ϊ“Ç¿ÖÆÀàÐÍת»»”¡£
ÔÚJavaScriptÖУ¬DoubleÀàÐͺÍIntÀàÐͶ¼ÊÇ¿´×÷ΪNumber¶ÔÏó£¬Òò´ËÎÞÂÛÊÇtypeof 1»¹ÊÇtypeof 1.0£¬¶¼ÊÇ·µ»Ønumber¡£ÕâÑùÎÒÃÇ¿ÉÒÔ²»ÓÃÈ¥¹ÜÊÇInt»¹ÊÇDoubleÀàÐÍ£¬ÈÃJavaScript½âÊÍÒýÇæÄÚ²¿È¥´¦Àí¡£
Èç¹ûÒª°ÑNumberת»»³ÉString£¬¿ÉÒÔʹÓÃNumberµÄtoString()·½·¨£¬£¨Ïó(1).toString()À¨ºÅ±ØÐë»òÕß 1 .toString()¿Õ¸ñ±ØÐ룬·ñÔò»á±àÒë³ö´í£¬Èç¹ûÊDZäÁ¿ÔòÎÞÐ裩£¬»òÕßµ÷ÓÃString()º¯Êý£¬ÕâÁ½ÖÖ·½·¨¶¼»á×Ô¶¯µ÷ÓýâÊÍÒýÇæÄÚ²¿µÄ NumberToString()£¬»òÕ߸ù¾Ý½øÖƵ÷ÓÃÆäËüº¯Êý£¬»ù±¾ÀàËÆ¡£
Èç¹ûÒª°ÑStringת»»³ÉNumber£¬¿ÉÒÔʹÓÃNumber()º¯Êý£¬Ëû»á×Ô¶¯ÅжÏStringÖÐÊÇÕûÊý»¹ÊǸ¡µãÊý£¬È»ºóÄÚ²¿Ê¹ÓÃÏàÓ¦µÄÊý¾ÝÀàÐÍ£¬ÁíÍâ¿ÉÒÔʹÓÃÈ«¾Öº¯ÊýparseInt()ºÍparseFloat()£¬ËûÃǸù¾ÝÄãµÄÒªÇó½øÐÐת»»¡£Í¬ÑùµÄ£¬ËûÃÇÔÚ½âÊÍÒýÇæÄÚ²¿»úÖÆÉÏÊÇʹÓÃÁË StringToNumber£¬StringToIntµÈµÈÄÚ²¿µÄº¯Êý¡£
¶øÈç¹ûÊÇDoubleת»»³ÉInt£¬±ØÐëʹÓÃMath.floor()º¯Êý£¨½ØβȡÕû£©»òÕßMath.round()£¨ËÄÉáÎåÈ룩
Intת»»³ÉDouble£¬ÎÞÐ뿼ÂÇÈκÎÎÊÌ⣬ֱ½Ó°ÑIntµ±³ÉDouble½øÐÐÔËËã
×¢£ºNumber¡¢Stringº¯ÊýÊÇÌØÊâµÄº¯Êý£¬ÔÚJSÒýÇæÖУ¬Ëû»á×Ô¶¯ÅжÏÊÇ×÷Ϊ¹¹Ô캯Êýµ÷Óû¹ÊÇÆÕͨµ÷Óã¬ËùÒԼȿÉÒÔʹÓÃnew¹Ø¼ü×Ö£¬Ò²¿ÉÒÔ×÷Ϊº¯ÊýÖ±½Óµ÷Óá£
Ïà¹ØÎĵµ£º
¼Ì³Ð»úÖÆ£¬Ëµµ½¼Ì³Ð£¬¾ÍÒªÏëµ½´Ó»ùÀ࿪ʼ£¬µ«ÊÇJavaScriptÖеÄÀàÓÐÁ½´óÀࣺһ£¬ÄÚǶµÄ£»¶þ£¬Óû§×Ô¶¨Ò壻һ°ãÇ°Õß²»»á±»ÓÃÀ´×ö»ùÀ࣬ÔÒòÊÇΪÁ˱£ÕÏjsµÄ°²È«¡£µ«ÊÇÎÒÃÇ¿ÉÒÔͨ¹ýprototypeÀ´¶Ô»ùÀà½øÐÐÀ©³ä£¬Ôö¼ÓÎÒÃÇÏëÒªµÄÊôÐԺͷ½·¨¡£ÒÔÏÂÊÇ×Ô¼º¶Ô¼Ì³ÐµÄ¼¸ÖÖ·½Ê½µÄÀí½â¡£
1> ¶ÔÏó ......
parseFloat ת»»³É¸¡µãÊý
parseInt ת»»³ÉÕûÊý.
ÕâÁ½¸öº¯Êý¶¼ÓÐЩÈÝ´íÐÔµÄ,±ÈÈç"123abc"»á±ä³É123.
Èç¹ûÂ¥Ö÷Ï£Íû¸ü׼ȷһЩ,Æäʵ¿ÉÒÔÅжÏÒ»ÏÂ,È»ºóÓÃeval,ÏñÕâÑù
²»¹ýÒ²¿ÉÒÔʹÓÃÕâÑùµÄ·½·¨:
var a = "234" ;
a = a.replace(/(^[\\s]*)|([\\s]*$)/g, "");
if( a !="" && !isNaN( a ) )
{//Èç¹ûÊÇÊý×Ö
a = e ......
(Ò»)¶ÔÏóð³ä
function A(name){
this.name = name;
this.sayHello = function(){alert(this.name+” say Hello!”);};
}
function B(name,id){
this.temp = A;
this.temp(name); &nbs ......
µÚÒ»ÖÖ·½·¨£ºÊ¹ÓÃinsertRowÌí¼ÓÐУ¬Ê¹ÓÃinsertCellÌí¼Óµ¥Ôª¸ñ£¬ÔÙÓÃinnerHTMLÌî³äµ¥Ôª¸ñ¡£Ê¹ÓÃdeleteRowɾ³ýÐУ¬´úÂëÈçÏ£º
Javascript´úÂ룺
function addRow()
{
var root = document.getElementById("tbody")
var&nb ......
Èç¹û¶ÔjavascriptÁ˽ⲻÊÇÌرðÉîÈëµÄ»°,ºÜÈÝÒ׾ͻáд³ö²»¼æÈݵĴúÂë(¾ÍÏñÎÒ),Õâʱºò¾ÍµÃÅжÏä¯ÀÀÆ÷ÁË¡£±ÈÈçʼþÕìÌý¡¢Ò»Ð©Êó±êºÍ¼üÅÌʼþ¡¢RangeµÈ,һЩ¶¼»á²»Ò»Ñù.ÏÂÃæÁгö¼¸ÖÖ³£Óõļì²âä¯ÀÀÆ÷·½·¨£¬ÒÔ÷ϹÛÖÚ!
¶ÔÏó/ÌØÕ÷¼ì²â·¨
¸Ã·½·¨ÊÇÒ»ÖÖÅжÏä¯ÀÀÆ÷ÄÜÁ¦£¨¶ø·Çä¯ÀÀÆ÷µÄÈ·ÇÐÐͺţ©µÄͨÓ÷½·¨¡£´ó²¿·ÖJSר¼ÒÈÏΪÕâ¸ö·½· ......