JavaScript ×Ö·û´®
JavaScript×Ö·û´®ÓÃÓÚ´æ´¢ºÍ´¦ÀíÎı¾¡£
×Ö·û´®¿ÉÒԴ洢һϵÁÐ×Ö·û£¬Èç"HAHA"£»
×Ö·û´®ÊÇ¿ÉÒÔ²åÈëµ½ÒýºÅÖеÄÈκÎ×Ö·û£¬¿ÉÒÔʹÓõ¥ÒýºÅ£¬Ò²¿ÉÒÔʹÓÃË«ÒýºÅ¡£
ÀýÈ磺
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <span id="demo"></span> <button onclick='this.innerHTML=Date()'>ʱ¼ä</button> </body> <script type="text/javascript"> var stringa = "¹þ¹þ"; var stringb = 'ÄãºÃ£¬Ä㻵£¬ÄãºÃ»µ£¡£¡'; </script> </html>
¿ÉÒÔʹÓÃË÷ÒýλÖÃÀ´·ÃÎÊ×Ö·û´®ÖеÄÿ¸ö×Ö·û£»
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <span id="demo"></span> <button onclick='this.innerHTML=Date()'>ʱ¼ä</button> </body> <script type="text/javascript"> var stringa = "¹þ¹þ"; var stringb = 'ÄãºÃ£¬Ä㻵£¬ÄãºÃ»µ£¡£¡'; //ͨ¹ýË÷Òý·ÃÎÊ×Ö·û´®ÖеÄÿ¸ö×Ö·û alert(stringb[3]); </script> </html>
×Ö·û´®ÖеÄË÷ÒýÊÇ´Ó0¿ªÊ¼µÄ£¬Ò²¾ÍÊÇ˵µÚÒ»¸ö×Ö·ûµÄË÷ÒýÖµÊÇ[0],µÚ¶þ¸öÊÇ[1],ÒÔ´ËÀàÍÆ¡£
¿ÉÒÔÔÚ×Ö·û´®ÖÐʹÓÃÒýºÅ£¬×Ö·û´®ÖеÄÒýºÅ²»ÒªÓëÒý×Å×Ö·û´®µÄÒýºÅÏàͬ¡£
ÀýÈ磺
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <span id="demo"></span> <button onclick='this.innerHTML=Date()'>ʱ¼ä</button> </body> <script type="text/javascript"> var stringa = "¹þ'dd'¹þ"; var stringb = 'ÄãºÃ£¬"Ä㻵"£¬ÄãºÃ»µ£¡£¡'; //ͨ¹ýË÷Òý·ÃÎÊ×Ö·û´®ÖеÄÿ¸ö×Ö·û alert(stringb[3]); </script> </html>Ò²¿ÉÒÔÔÚ×Ö·û´®ÖÐÌí¼ÓתÒå×Ö·ûÀ´Ê¹Óà ÒýºÅ \ ¾ÍÊÇתÒå×Ö·û
ÀýÈ磺
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <span id="demo"></span> <button onclick='this.innerHTML=Date()'>ʱ¼ä</button> </body> <script type="text/javascript"> var stringa = "¹þ\'dd\'¹þ"; var stringb = 'ÄãºÃ£¬\"Ä㻵\"£¬ÄãºÃ»µ£¡£¡'; //ͨ¹ýË÷Òý·ÃÎÊ×Ö·û´®ÖеÄÿ¸ö×Ö·û alert(stringb[3]); </script> </html>×Ö·û´®³¤¶È
¿ÉÒÔʹÓÃÄÚÖÃÊôÐÔ length À´¼ÆËã×Ö·û´®µÄ³¤¶È£º
ÀýÈ磺
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <span id="demo"></span> <button onclick='this.innerHTML=Date()'>ʱ¼ä</button> </body> <script type="text/javascript"> var stringa = "¹þ\'dd\'¹þ"; var stringb = 'ÄãºÃ£¬\"Ä㻵\"£¬ÄãºÃ»µ£¡£¡'; //ͨ¹ýË÷Òý·ÃÎÊ×Ö·û´®ÖеÄÿ¸ö×Ö·û alert(stringb.length);//²é¿´×Ö·û´®stringbµÄ³¤¶È </script> </html>ÌØÊâ×Ö·û
ÔÚJavaScriptÖÐ×Ö·ûÖÐдÔÚµ¥ÒýºÅ»òÕßË«ÒýºÅÖС£
Òª²»È»ÀàËÆÓÚÕâÑùµÄ×Ö·û´®ÊÇÎÞ·¨½âÎöµÄ ¡ú_¡ú "ÍÛ¹þ¹þ¹þ"À²À²"ôôßÕ"£»
ÄÅÔõô½â¾öÄØ£¿£¿£¿Ê¹ÓÃתÒå×Ö·û¾ÍºÃÁË£¬¡ú_¡ú "ÍÛ¹þ¹þ¹þ\"À²À²\"ôôßÕ"£»
\ ¾ÍÊÇתÒå×Ö·û£¬¾ÍÊǽ«ÌØÊâµÄ×Ö·ûת»»Îª×Ö·û´®×Ö·û¡£Ïêϸ¼ûϱí
×Ö·û´®¿ÉÒÔÊǶÔÏó
ͨ³£JavaScript×Ö·û´®ÊÇÔʼֵ£¬¿ÉÒÔʹÓÃ×Ö·û´´½¨£ºvar aa= "AA";
µ«ÊÇÒ²¿ÉÒÔʹÓÃnew¹Ø¼ü×Ö½«×Ö·û´®¶¨ÒåΪһ¸ö¶ÔÏó£ºvar stringaa = new String("°²È»");
Ò»°ã²»½¨Òé´´½¨String¶ÔÏ󣬻áÓ°ÏìÖ´ÐÐËٶȣ¬²¢¿ÉÄܲúÉúÆäËûÓ°Ïì¡£
ÀýÈ磺
var aa = "AA"; var bb = new String("AA"); alert(aa === bb); //·µ»ØÖµÊÇfalse ÒòΪ aaÊÇ×Ö·û´® bb ÊǶÔÏó×Ö·û´®ÊôÐԺͷ½·¨
Ôʼֵ×Ö·û´®Ã»ÓÐÊôÐԺͷ½·¨£¬ÒòΪËûÃDz»ÊǶÔÏó¡£
Ôʼֵ×Ö·û´®¿ÉÒÔʹÓÃJavaScriptµÄÊôÐԺͷ½·¨£¬ÒòΪJavaScriptÔÚÖ´Ðз½·¨ºÍÊôÐÔʱ¿ÉÒÔ°ÑÔʼֵµ±×ö¶ÔÏó¡£
×Ö·û´®ÊôÐÔ
×Ö·û´®·½·¨
×ܽ᣺ÒÔÉϾÍÊDZ¾ÆªÎĵÄÈ«²¿ÄÚÈÝ£¬Ï£ÍûÄܶԴó¼ÒµÄѧϰÓÐËù°ïÖú¡£¸ü¶àÏà¹Ø½Ì³ÌÇë·ÃÎÊJavaScriptÊÓƵ½Ì³Ì£¬jQueryÊÓƵ½Ì³Ì£¬bootstrap½Ì³Ì£¡
ÒÔÉϾÍÊÇJavaScriptѧϰ֮ʲôÊÇ×Ö·û´®£¿js×Ö·û´®Ïà¹Ø֪ʶ½éÉܵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢phpÖÐÎÄÍøÆäËüÏà¹ØÎÄÕ£¡
ÍøÕ¾½¨ÉèÊÇÒ»¸ö¹ãÒåµÄÊõÓº¸ÇÁËÐí¶à²»Í¬µÄ¼¼ÄܺÍѧ¿ÆÖÐËùʹÓõÄÉú²úºÍά»¤µÄÍøÕ¾¡£
……