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 = {
//...
};
Ïà¹ØÎĵµ£º
½ñÌìÔÚѧϰBomʱÓöµ½ÁËÒ»¸ö´íÎó£º
Static overflow at 7
´íÎóÔÒò£º×Ô¶¨ÒåÁËÒ»¸ö scrollTo()£¬Óëϵͳwindow.scrollTo()³åÍ»£¬ÒÔÖÂÒýÆðËÀÑ»·£¬´Ë´íÎóÔÚµ¯³ö´íÎó¿ò£¬¶øÔÚFFÏÂûÓз´Ó¦£¬µ«functionÒ²²»Ö´ÐС£ÁíÍâ<img src="" onerror=""/>Ò²¿ÉÄܳöÏÖÕâÖÖÇé¿ö¡£ÏêϸÇë²Î¿¼£ºhttp://www.cnblogs.com/S.Sams/archive/200 ......
Õâ¸öЧ¹ûÓ¦¸Ã²»ËãÊ²Ã´Ï¡Ææ£¬ÍøÉÏÒ²ÓÐÏֳɵĴúÂ룬ÎÒÕâ¸öÒ²Ã»Ê²Ã´ÌØ±ðµÄµØ·½£¬Ö»ÊÇÒòΪÎÒ×Ô¼ºÐ´µÄ£¬Ò²ËãÊÇΪѧϰDOMºóÒ»¸öÁ·Ï°£»ÔÚIEϲâÊÔͨ¹ý£»
ʵÏÖЧ¹ûÊÇÕâÑùµÄ£º
¶ÁÈ¡XMLÎĵµ£»
²ÉÓõݹéÉú³ÉÎÞÏÞ¼¶µÄÊ÷Ðβ˵¥£»
Äܹ»ÏìÓ¦Êó±êʼþ£¬Õ¹¿ªÓë²ðµþ×Ó¼¶²Ëµ¥£»
Ê×ÏÈÊÇÉú³ÉÒ»¸öXMLÎĵµ£¬ÎÒÓõÄÊÇXML SpyµÄ±à¼Æ÷£»
< ......
Ò»¡¢deleteÔËËã·ûɾ³ý¶ÔÒÔǰ¶¨ÒåµÄ¶ÔÏóÊôÐÔ»ò·½·¨µÄÒýÓãº
var o=new Object();
o.name="hello";
alert(o.name); //Êä³ö“hello”
delete o.name£»
alert(o.name); //Êä³ö& ......
×ªÔØ×Ô£ºhttp://www.ruanyifeng.com/blog/2009/09/find_element_s_position_using_javascript.html
Áíһƪ£ºhttp://blog.csdn.net/ivan820819/archive/2009/09/03/4515122.aspx
ÖÆ
×÷
ÍøÒ³µÄ¹ý³ÌÖУ¬ÄãÓÐʱºòÐèÒªÖªµÀij¸öÔªËØÔÚÍøÒ³ÉϵÄÈ·ÇÐλÖá£
ÏÂÃæµÄ½Ì³Ì×ܽáÁË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 ......