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

Javascriptѧϰ±Ê¼ÇÒ» ¶ÔÏó

 ¼ìË÷:
1 ÓÃ||À´Ìî³äĬÈÏÖµ
var status = flight.status || "unknown";
2 ʹÓÃ&&·ÀÖ¹TypeError
flight.equipment.model //throw "TypeError"
flight.equipment && flight.equipment.model //undefined

ÒýÓÃ
var a={},b={},c={};
document.writeln(a===b); //false
Ô­ÐÍ
JavascriptÌṩµÄʵÏÖ»úÖÆ£º
var stooge = {
"first-name":"Jerome",
"last-name":"Howard"
};
var temp = function(){};
temp.prototype=stooge;
var another_stooge= new temp;
¿ÉÒÔÖ±½Ó¸øObject¼Ó¸ö·½·¨À´¼ò»¯
if (typeof Object.beget !== 'function'){
Object.beget = function (o){
var F = function (){};
F.prototype = o;
return new F();
}
}
var another_stooge =Object.beget(stooge);
another_stooge["first-name"] = 'Harry';
document.writeln(another_stooge["first-name"]); //Harry
document.writeln(another_stooge["last-name"]); //Howard
document.writeln(stooge["first-name"]); //Jerome

·´Éä
typeof¿ÉÒÔ·ÃÎÊÔ­ÐÍÁ´
document.writeln(typeof flight.toString); //function
hasOwnPropertyÔò²»ÐÐ
 document.writeln(flight.hasOwnProperty('toString')); //false
ö¾Ù
ʹÓÃfor inö¾ÙÊôÐÔ µÄ˳ÐòÊDz»È·¶¨µÄ£¬¶øÇÒÐèҪʹÓÃhasOwnProperty£¬²¢Ê¹ÓÃtypeofÅųýº¯Êý
×îºÃ
var properties = [
"first-name",
"last-name"
];
for (var i = 0; i < properties.length; i+=1){
document.writeln(properties[i] + ": " + stooge[properties[i]]);
}
ɾ³ý
ɾ³ý²»»á´¥¼°Ô­ÐÍÁ´£¬É¾³ý¶ÔÏóÊôÐÔ£¬Ô­ÐÍÁ´µÄÊôÐÔ¸¡ÏÖ³öÀ´
anothet_stooge["first-name"] = "Jack";
document.writeln(anothet_stooge["first-name"]);//Jack
delete anothet_stooge["first-name"];
document.writeln(anothet_stooge["first-name"]);//Jerome
ÃüÃû¿Õ¼ä
var MYAPP= {}£»
MYAPP.stooge = {
//...
};


Ïà¹ØÎĵµ£º

Javascript¹Ø¼ü×Ö ¼Ç¼

¸ÕÔÚCSDNÉÏ¿´µ½Ò»ÆªJAVASCRIPTµÄÃæÊÔÌâÄ¿£¬ÆäÖÐÓÐÒ»¸öÌâÄ¿ÊǹØÓÚjavascript¹Ø¼ü×ÖµÄÎÊÌ⣬ÊÔ×öÁËһϣ¬½á¹û×ö´íÁË¡£°¦¡£º¹Ò»¸ö
ÓÚÊÇÉÏÍøÕÒÁËһϣ¬Ôڴ˼ǼÏÂÀ´£¬ÒÔ×ÔÃã¡£
Javascript¹Ø¼ü×Ö(Reserved
Words)ÊÇÖ¸ÔÚJavascriptÓïÑÔÖÐÓÐÌØ¶¨º¬Ò壬³ÉΪJavascriptÓï·¨ÖÐÒ»²¿·ÖµÄÄÇЩ×Ö¡£Javascript¹Ø¼ü×ÖÊDz»ÄÜ×÷Ϊ±äÁ¿Ãû
......

JavaScriptÃæÏò¶ÔÏóÏê½â

ÄÚÖÃÀà
JavaScriptÊÇÒ»ÖÖ»ùÓÚ¶ÔÏóµÄ½âÊÍÐÔ±à³ÌÓïÑÔ£¬ËùÓеÄÔªËØ£¬ÎÒÃǶ¼¿ÉÒÔÀí½âΪ¶ÔÏó£¬Ã¿¸ö¶ÔÏóÒ²¿ÉÒÔÀí½âΪN¶àÊôÐԵļ¯ºÏ¡£ÔÚÌÖÂÛ×Ô¶¨ÒåÀà֮ǰ£¬ÎÒÃÇÏÈ¿´Ò»ÏÂÄÚÖõÄÀà¡£×÷Ϊ½âÊÍÐÔÓïÑÔ£¬JavaScriptÔÊÐíÎÒÃÇÔÚÈκÎʱºòΪ¶ÔÏóÌí¼ÓÊôÐÔ¡£ËùÒÔÎÒÃÇ¿ÉÒÔÏÈ¿´Ò»¶Î¼òµ¥µÄ´´½¨¶ÔÏóµÄ´úÂëÆ¬¶Î¡£ÕâÀïµÄ“new Object”Ò²¿ ......

javascriptÖеÄÄ£¿éºÍÃû×Ö¿Õ¼ä

JavaScriptÖеÄÄ£¿éºÍÃû×Ö¿Õ¼äÊDz»¿ÉÇø·ÖµÄÄÚÈÝ¡£
ÎÒÃǶ¨ÒåµÄÿ¸öµ¥¶ÀµÄº¯Êý¶¼ÊÇ×÷Ϊȫ¾Ö¶ÔÏóµÄÒ»¸öÊôÐÔ¡£¶øJavaScript´úÂëÄ£¿éËù±ØÐë×ñÑ­µÄ×îÖØÒªµÄ¹æÔò¾ÍÊÇ£º±ÜÃⶨÒåÈ«¾Ö±äÁ¿¡£ÒòΪ£¬µ±¶¨ÒåÒ»¸öÈ«¾Ö±äÁ¿Ê±£¬¶¼Òª±»ÆäËûÄ£¿é¸²¸ÇµÄΣÏÕ£¬ËùÒÔÄ£¿é»¯±àÂëÒªÓÃÈçÏ·½Ê½£º
var ModuleClass={};
ModuleClass.º¯ÊýÃû1=functio ......

³£ÓÃ:javascript×Ö·û´®º¯Êý ÊÕ²Ø

³£ÓÃ:javascript×Ö·û´®º¯Êý ÊÕ²Ø
concat
½«Á½¸ö»ò¶à¸ö×Ö·ûµÄÎı¾×éºÏÆðÀ´£¬·µ»ØÒ»¸öеÄ×Ö·û´®¡£
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®µÚÒ»´¦³öÏÖµÄË÷Òý£¨´Ó×óµ½ÓÒËÑË÷£©¡£Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = a.indexOf ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ