ºËÐÄJavaScript»ù´¡ 2£¨Ñ§Ï°±Ê¼Ç£©
²Î¿¼×ÊÁÏ:¡¶javascriptȨÍþÖ¸ÄϵÚÎå°æ¡·
===============±äÁ¿==============
1¡¢javaScriptÊÇÒ»ÖÖÈõÀàÐ͵ÄÓïÑÔ£¬ÓÃvarÓï¾ä¼´¿ÉÉùÃ÷Ò»¸ö±äÁ¿¡£
2¡¢Èç¹û²»ÓÃvarÓï¾äÉùÃ÷¶øÖ±½Ó¸øÒ»¸ö±äÁ¿¸³Öµ£¬ÄÇÕâ¸ö±äÁ¿½«±»ÒþʽÉùÃ÷Ϊȫ¾Ö±äÁ¿¡£
3¡¢Èç¹ûº¯ÊýÄÚ²¿ÓÃvarÓï¾äÉùÃ÷ÁËÒ»¸öÓëijȫ¾Ö±äÁ¿Í¬ÃûµÄ±äÁ¿£¬ÔòÔÚº¯ÊýÖÐÈ«¾Ö±äÁ¿±»ÆÁ±ÎÁË£¬¼´Ê¹Õâ¸ö±äÁ¿µÄ¶¨ÒåÊÇÔÚº¯ÊýµÄ
×îºóÒ»ÐС£
4¡¢ÎÒÃÇ¿ÉÒÔÔÚforÓï¾äÖж¨Òå±äÁ¿£¬Èçfor(var i=0;i<10;i++),ÔÚÆäËüµÄһЩÓïÑÔÖУ¬ÕâÀïµÄiÔÚÍ˳öÑ»·ºóÉúÃü¾Í½áÊøÁË£¬µ«
javascriptÖУ¬iÔÚ°üº¬ËüµÄÕû¸öº¯ÊýÖпÉÓá£
==============ÔËËã·û=======
1¡¢È¡Ä£ÔËËã·û%Ò»°ãÓÃÓÚÕûÊý£¬µ«ÔÚ¸¡µãÊýÖÐÒ²ÊÊÓá£-4.3%2.1=-0.1¡£ÁíÍ⣬ȡģÔËËãºóµÄ½á¹ûµÄ·ûºÅºÍµÚÒ»¸öÔËËãÊý±£³ÖÒ» Ö¡£
2¡¢==£¨ÏàµÈ£©Óë===£¨ÍêÈ«µÈͬ£©¡£¶ÔÓÚ»ù±¾ÀàÐÍ£¬Èô²ÎÓë±È½ÏµÄË«·½ÀàÐͲ»Í¬£¬Ç°Õß»áÏÈת»»ÀàÐÍÖÁÒ»ÖÂÔٱȽϣ¬¶øºóÕß²»
»á¡£×¢ÒâµÄÊÇÖµNaNÓÀÔ¶²»ÓëÈκÎÖµµÈͬ£¬ÐèÓÃisNaN£¨£©À´²âÊÔÒ»¸öÖµÊÇ·ñNaN¡£
3¡¢inÔËËã·û¡£ÈçA in B¡£ËüÓÃÀ´ÅжÏAÊÇ·ñB×Ô¼ºµÄ»ò¼Ì³ÐÀ´µÄÒ»¸öÊôÐÔ¡£A±ØÐëÊÇ×Ö·û´®»ò¿ÉÒÔת»»³É×Ö·û´®£¬B±ØÐëÊǶÔÏó»òÕß
Êý×é¡£Èç¹ûA»òB²»·ûºÏÒªÇóÔò»á·¢ÉúÔËÐÐʱ´íÎó£¬Èç¹ûA²»ÊÇBµÄÊôÐÔ£¬·µ»Øfalse¡£
4¡¢instanceofÔËËã·û¡£ÈçA in B¡£ËüÓÃÀ´ÅжÏAÊÇ·ñBÖеÄÒ»¸öʵÀý£¬·µ»Ø²¼¶ûÖµ¡£A±ØÐëÊÇÒ»¸ö¶ÔÏó£¬B±ØÐëÊÇÒ»¸ö¶ÔÏóÀàµÄÃû
×Ö»òÕß˵¹¹Ô캯Êý¡£Èç¹û×ó±ß²»ÊǶÔÏó»òÓÒ±ßÊǶÔÏ󵫲»Êǹ¹Ô캯Êý£¬½«·µ»Øfalse£¬Èç¹ûÓұ߸ù±¾²»ÊǶÔÏó£¬Ôò²úÉúÔËÐÐʱ´í
Îó¡£
5¡¢Âß¼Óë&&ºÍÂß¼»ò||¡£ÈçA && B¡£µ±AµÄ¼ÆËã½á¹ûÊÇ¿ÉÒÔת»»³ÉfalseµÄÖµ£¬Ôò·µ»ØAµÄ¼ÆËã½á¹û£¬·ñÔò¼ÆËãBµÄÖµ·µ»Ø¡£
A || BÒ²Ò»Ñù·µ»ØÏàÓ¦±í´ïʽµÄ¼ÆËã½á¹û¡£µ«ÔÚjavascript1.0ºÍ1.1ÖУ¬·µ»ØÖµÊDz¼¶ûÖµ¡£
6¡¢typeof·µ»ØÈÎÒâÔËËãÊýµÄÀàÐÍ¡£µ«ËüÖ»ÄÜÇø·ÖÔËËãÊýÊÇ»ù±¾ÀàÐÍ»¹ÊǶÔÏó£¬ÒòΪ¶ÔËùÓжÔÏó°üÀ¨nullËü¶¼·µ»Øobject¡£¶Ô»ù±¾
ÀàÐÍ£¬Ëü·Ö±ð·µ»Ønumber¡¢string¡¢boolean¡£¶Ôº¯ÊýËü·µ»Øfunction£¬¶Ô䶨ÒåµÄÖµ£¬Ëü·µ»Øundefined¡£
7¡¢deleteÔËËã·ûɾ³ýÖ¸¶¨µÄ¶ÔÏóÊôÐÔ¡¢Êý×éÔªËØ»ò±äÁ¿¡£ÓÃvarÓï¾äÉùÃ÷µÄ±äÁ¿ÊDz»¿ÉÓÃdeleteɾ³ýµÄ¡£É¾³ý³É¹¦Ê±·µ»Øtrue£¬
²»³É¹¦Ê±·µ»Øfalse¡£µ«Èç¹ûÔËËãÊýÊÇÒ»
Ïà¹ØÎĵµ£º
Javascriptº¯ÊýÀàÐÍÅжÏÍêÃÀ½â¾ö·½°¸
ÔÚÅжϺ¯ÊýÀàÐÍʱ£¬ÎÒÃÇͨ³£Ê¹ÓÃtypeof·½·¨£¬Ò»°ãÇé¿öÏ£¬Ëü»áµÃµ½ÎÒÃÇËùÔ¤ÏëµÄЧ¹û¡£µ«ÊÇ£¬ÓÐһЩϸ½Ú²¢²»ÎªÎÒÃÇËùÊìÖª¡£John Resig ÔÚ·ÖÎöÁËÕâЩϸ½ÚÖ®ºó£¬ÎªÎÒÃÇÌṩÁËÒ»¸öÍêÃÀµÄ½â¾ö·½°¸£¬±¾ÎĽ«×÷Ïêϸ½éÉÜ£º
Ò»¡¢´«Í³·½·¨²»ÎªÈËËùÖªµÄϸ½Ú
ºÁÎÞÒÉÎÊ£¬ÔÚÅжϺ¯ÊýÀàÐÍʱ£¬ÎÒÃÇÊ ......
! È¥³ý×Ö·û´®Á½¶Ë¿Õ¸ñµÄ´¦Àí
¡¡¡¡Èç¹û²ÉÓô«Í³µÄ·½Ê½,¾ÍÒª¿ÉÄܾÍÒª²ÉÓÃÏÂÃæµÄ·½Ê½ÁË
¡¡¡¡//Çå³ý×ó±ß¿Õ¸ñ
¡¡¡¡function js_ltrim(deststr)
¡¡¡¡{
¡¡¡¡if(deststr==null)return "";
¡¡¡¡var pos=0;
¡¡¡¡var retStr=new String(deststr);
¡¡¡¡if (retStr.lenght==0) return retStr;
¡¡¡¡while (retStr.substring(pos, ......
ÎÊ:
Hi,
I have this C#/ASP.NET/.aspx page with a string variable named myString with the value "Mario Gamito".
How can I access "Mario Gamito" from within a JavaScript function, i. e., the variable's value ?
Already tried '" + mystring + "' but it doesn't works.
Any help would be appreciated.
......
´ó²¿·ÖµÄ½âÊÍÐͽű¾ÓïÑÔ¶¼Ìṩ eval ·½·¨À´Íê³É¶¯Ì¬´úÂëµÄ½âÊÍÖ´ÐУ¬ C# È´²¢²»Ìṩ£¨Ïò Java ѧϰ£©¡£²»¹ýÔÚ .NET Framework Àà¿âÀïÃæÌṩµÄ Microsoft.JScript ÃüÃû¿Õ¼äµ¹ÊÇ°üº¬ÁËÖ§³ÖʹÓÃJScript ÓïÑÔ±àÒëºÍÉú³É´úÂëµÄÀà¡£
ÏÈÉÏ´úÂ룺
¡¡¡¡¸ÃÀàÐèÒªÄãÌí¼Ó¶Ô³ÌÐò¼¯ Microsoft.JScript µÄÒýÓã»Èç¹û°Ñ“current v ......