Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScript ÃæÏò¶ÔÏó

(תhttp://www.javaeye.com/topic/155109)
JavaScript ÊÇÃæÏò¶ÔÏóµÄ¡£µ«ÊDz»ÉÙÈ˶ÔÕâÒ»µãÀí½âµÃ²¢²»È«Ãæ¡£
ÔÚ JavaScript ÖУ¬¶ÔÏó·ÖΪÁ½ÖÖ¡£Ò»ÖÖ¿ÉÒÔ³ÆΪ“ÆÕͨ¶ÔÏ󔣬¾ÍÊÇÎÒÃÇËùÆÕ±éÀí½âµÄÄÇЩ£ºÊý×Ö¡¢ÈÕÆÚ¡¢Óû§×Ô¶¨ÒåµÄ¶ÔÏó£¨È磺{}£©µÈµÈ¡£
»¹ÓÐÒ»ÖÖ£¬³ÆΪ“·½·¨¶ÔÏ󔣬¾ÍÊÇÎÒÃÇͨ³£¶¨ÒåµÄ function¡£Äã¿ÉÄܾõµÃÆæ¹Ö£º·½·¨¾ÍÊÇ·½·¨£¬Ôõô³ÉÁ˶ÔÏóÁË£¿µ«ÊÇÔÚ JavaScript ÖУ¬·½·¨µÄÈ·ÊDZ»µ±³É¶ÔÏóÀ´´¦ÀíµÄ¡£ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÀý×Ó£º
Js´úÂë
function func() {alert('Hello!');}   
alert(func.toString());  
function func() {alert('Hello!');}
alert(func.toString());
ÔÚÕâ¸öÀý×ÓÖУ¬func ËäÈ»ÊÇ×÷Ϊһ¸ö·½·¨¶¨ÒåµÄ£¬µ«Ëü×ÔÉíÈ´°üº¬Ò»¸ö toString ·½·¨£¬ËµÃ÷ func ÔÚÕâÀïÊDZ»µ±³ÉÒ»¸ö¶ÔÏóÀ´´¦ÀíµÄ¡£¸ü׼ȷµÄ˵£¬func ÊÇÒ»¸ö“·½·¨¶ÔÏó”¡£ÏÂÃæÊÇÀý×ӵļÌÐø£º
Js´úÂë
func.name = “I am func.”;   
alert(func.name);  
func.name = “I am func.”;
alert(func.name);
ÎÒÃÇ¿ÉÒÔÈÎÒâµÄΪ func ÉèÖÃÊôÐÔ£¬Õâ¸ü¼ÓÖ¤Ã÷ÁË func ¾ÍÊÇÒ»¸ö¶ÔÏó¡£ÄÇô·½·¨¶ÔÏóºÍÆÕͨ¶ÔÏóµÄÇø±ðÔÚÄÄÀïÄØ£¿Ê×ÏÈ·½·¨¶ÔÏóµ±È»ÊÇ¿ÉÒÔÖ´Ðеģ¬ÔÚËüºóÃæ¼ÓÉÏÒ»¶ÔÀ¨ºÅ£¬¾ÍÊÇÖ´ÐÐÕâ¸ö·½·¨¶ÔÏóÁË¡£
Js´úÂë
func();  
func();
ËùÒÔ£¬·½·¨¶ÔÏó¾ßÓжþÖØÐÔ¡£Ò»·½ÃæËü¿ÉÒÔ±»Ö´ÐУ¬ÁíÒ»·½ÃæËüÍêÈ«¿ÉÒÔ±»µ±³ÉÒ»¸öÆÕͨ¶ÔÏóÀ´Ê¹Óá£ÕâÒâζ×ÅʲôÄØ£¿ÕâÒâζ×Å·½·¨¶ÔÏóÊÇ¿ÉÒÔÍêÈ«¶ÀÁ¢ÓÚÆäËû¶ÔÏó´æÔڵġ£ÕâÒ»µãÎÒÃÇ¿ÉÒÔͬ Java ±È½Ïһϡ£ÔÚ Java ÖУ¬·½·¨±ØÐëÔÚijһ¸öÀàÖж¨Ò壬¶ø²»Äܵ¥¶À´æÔÚ¡£¶ø JavaScript ÖоͲ»ÐèÒª¡£
·½·¨¶ÔÏó¶ÀÁ¢ÓÚÆäËû·½·¨£¬¾ÍÒâζ×ÅËüÄܹ»±»ÈÎÒâµÄÒýÓúʹ«µÝ¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
Js´úÂë
function invoke(f) {   
    f();   
}   
invoke(func);  
function invoke(f) {
f();
}
invoke(func);
½«Ò»¸ö·½·¨¶ÔÏó func ´«µÝ¸øÁíÒ»¸ö·½·¨¶ÔÏó invoke£¬ÈúóÕßÔÚÊʵ±µÄʱºòÖ´ÐÐ func¡£Õâ¾ÍÊÇËùνµÄ“»Øµ÷”ÁË¡£ÁíÍ⣬·½·¨¶ÔÏóµÄÕâÖÖÌØÊâÐÔ£¬Ò²Ê¹µÃ this ¹Ø¼ü×Ö²»ÈÝÒ×°ÑÎÕ¡£Õâ·½ÃæÏà¹ØÎÄÕ²»ÉÙ£¬ÕâÀﲻ׸ÊöÁË¡£
³ýÁË¿ÉÒÔ±»Ö´ÐÐÒÔÍ⣬·½·¨¶ÔÏó»¹ÓÐÒ»¸öÌØÊâµÄ¹¦Ó㬾ÍÊÇËü¿ÉÒÔͨ¹ý new ¹Ø¼ü×ÖÀ´´´½¨ÆÕͨ¶ÔÏ


Ïà¹ØÎĵµ£º

[ת]Top 10 Things that JavaScript Got Wrong

to make a note that I love JavaScript. This article is only meant for some fun, and for us to be aware of some its short-comings.
1. The Name. JavaScript is NOT Java
We'll start with a fun jab at the name choice. While it was originally called Mocha, and then LiveScript, it was later changed to J ......

JavaScriptʵÏÖÀàËÆExcel¹¦ÄÜ

//¸´ÖÆËùÑ¡±í¸ñµÄÊý¾Ýµ½¼ôÌù°å ×÷Õߣºxx
function copyData(){
var content = "";
var tbl = getTbl();
//»ñÈ¡ËùÑ¡µÄËùÓÐÊý¾Ý
for(j = start_Row; j <= end_Row; j++)
{
for(i = start_Col; i <= end_Col; i++)
{
content += (tbl.rows[j].cells[i].childNodes[0].value);
if(i != end_ ......

javascript ʵÏÖTab»¬¶¯

Ïȸø³ö»ù±¾µÄHTMLÎļþ£º
<ul>
  <li id="m01"></li>
  <li id="m01"></li>
  <li id="m01"></li>
</ul>
<div>
 <div id="C01"> </div>
 <div id="C02">&n ......

javascript ÅжÏÎļþÊÇ·ñ´æÔÚ ÕûÀí

javascript ÅжÏÎļþÊÇ·ñ´æÔÚ
<title>³£ÓÃÏÂÔØ</title>
    <script type="text/javascript" >      
//ÅжϷþÎñÆ÷ÉϵÄÎļþ£¨ÍøÂçÎļþÊÇ·ñ´æÔÚ£©    
function getURL()  
     &nb ......

JavaScript_¶¯Ì¬Ôö¼Ó/ɾ³ýÊäÈë¿ò

±¾ÎÄÖ÷Òª½éÉÜÈçºÎ¶¯Ì¬µÄÔö¼Ó¡¢É¾³ýÊäÈë¿ò£¬²¢»ñÈ¡ÊäÈë¿òÖеÄÖµ~~
<html>
<head>
<title>JavaScript_¶¯Ì¬Ôö¼Ó/ɾ³ýÊäÈë¿ò_°¢·½Ë÷</title>
<script type="text/javascript">
<!--
var idNumber = 1,id="tableAFS";
function addTextBox() {
idNumber++;
//ÕâÀïÎÒÃÇ´´½¨Ò»¸ölab ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ