javascript prototype½éÉܵÄÎÄÕÂ
JavaScriptÊÇ»ùÓÚ¶ÔÏóµÄ£¬ÈκÎÔªËض¼¿ÉÒÔ¿´³É¶ÔÏó¡£È»¶ø£¬ÀàÐͺͶÔÏóÊDz»Í¬µÄ¡£±¾ÎÄÖУ¬ÎÒÃdzýÁËÌÖÂÛÀàÐͺͶÔÏóµÄһЩÌصãÖ®Í⣬¸üÖØÒªµÄÊÇÑо¿ÈçºÎд³öºÃµÄ²¢ÇÒÀûÓÚÖØÓõÄÀàÐÍ¡£±Ï¾¹£¬JavaScriptÕâÖÖÁ÷ÐеĽű¾ÓïÑÔÈç¹ûÄܹ»½øÐÐÁ¼ºÃµÄ·â×°£¬²¢ÐγÉÒ»¸öÅÓ´óµÄÀàÐͿ⣬¶ÔÓÚÖØÓÃÊǷdz£ÓÐÒâÒåµÄ¡£
ÍøÉ϶ÔÓÚprototypeµÄÎÄÕºܶ࣬һֱûÃ÷°×ºËÐĵÄ˼Ïë¡£×îºóдÁ˺ܶàÀý×Ó´úÂëºó²ÅÃ÷°×£ºprototypeÖ»ÄÜÓÃÔÚÀàÐÍÉÏ¡£
ÒÔÏÂÊÇһЩ¹ØÓÚÀàÐͺͶÔÏóµÄÀý×Ó£¬´ó¼Ò¿´ÍêÀý×Óºó¿ÉÄܸüÈÝÒ×Àí½âÀàÐͺͶÔÏóÖ®¼äµÄÁªÏµ£º
Àý×Ó´úÂë ˵Ã÷
1 Object.prototype.Property = 1;
Object.prototype.Method = function ()
{
alert(1);
}
var obj = new Object();
alert(obj.Property);
obj.Method();
¿ÉÒÔÔÚÀàÐÍÉÏʹÓÃproptotypeÀ´ÎªÀàÐÍÌí¼ÓÐÐΪ¡£ÕâЩÐÐΪֻÄÜÔÚÀàÐ͵ÄʵÀýÉÏÌåÏÖ¡£
JSÖÐÔÊÐíµÄÀàÐÍÓÐArray, Boolean, Date, Enumerator, Error, Function, Number, Object, RegExp, String
2 var obj = new Object();
obj.prototype.Property = 1; //Error
//Error
obj.prototype.Method = function()
{
alert(1);
}
ÔÚʵÀýÉϲ»ÄÜʹÓÃprototype£¬·ñÔò·¢Éú±àÒë´íÎó
3 Object.Property = 1;
Object.Method = function()
{
alert(1);
}
alert(Object.Property);
Object.Method();
¿ÉÒÔΪÀàÐͶ¨Ò哾²Ì¬”µÄÊôÐԺͷ½·¨£¬Ö±½ÓÔÚÀàÐÍÉϵ÷Óü´¿É
4 Object.Property = 1;
Object.Method = function()
{
alert(1);
}
var obj = new Object();
alert(obj.Property); //Error
obj.Method(); //Error
ʵÀý²»Äܵ÷ÓÃÀàÐ͵ľ²Ì¬ÊôÐÔ»ò·½·¨£¬·ñÔò·¢Éú¶ÔÏó䶨ÒåµÄ´íÎó¡£
5 function Aclass()
{
this.Property = 1;
this.Method = function()
{
alert(1);
}
}
var obj = new Aclass();
alert(obj.Property);
obj.Method();
Õâ¸öÀý×ÓÑÝʾÁËͨ³£µÄÔÚJavaScriptÖж¨ÒåÒ»¸öÀàÐ͵ķ½·¨
6 function Aclass()
{
this.Property = 1;
this.Method = function()
{
alert(1);
}
}
Aclass.prototype.Property2 = 2;
Aclass.prototype.Method2 = function
{
alert(2);
}
var obj = new Aclass();
alert(obj.Property2);
obj.Method2();
¿ÉÒÔÔÚÍ
Ïà¹ØÎĵµ£º
Data Format Conclusions Êý¾Ý¸ñʽ×ܽá
Favor lightweight formats in general; the best are JSON and a character-delimited custom format. If the data set is large and parse time becomes an issue, use one of these two techniques:
×ܵÄÀ´ËµÔ½ÇáÁ¿¼¶µÄ¸ñʽԽºÃ£¬× ......
Working Around Caching Issues ¹ØÓÚ»º´æÎÊÌâ
Adequate cache control can really enhance the user experience, but it has a downside: when revving up your application, you want to make sure your users get the latest version of the static content. This is accomplished by renaming ......
Fiddler
Fiddler is an HTTP debugging proxy that examines the assets coming over the wire and helps identify any loading bottlenecks. Created by Eric Lawrence, this is a general purpose network analysis tool for Windows that provides detailed reports on any browser or web request. ......