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

javascript¼Ì³Ð·½Ê½Ö®Ò»

ÃæÏò¶ÔÏóµÄÓïÑÔ¶àÊý¶¼Ö§³Ö¼Ì³Ð£¬¼Ì³Ð×îÖØÒªµÄÓŵã¾ÍÊÇ´úÂ븴Ó㬴Ӷø¹¹½¨´óÐÍÈí¼þϵͳ¡£Èç¹ûÒ»¸öÀàÄܹ»ÖØÓÃÁíÒ»¸öÀàµÄÊôÐԺͻò·½·¨£¬¾Í³Æ֮Ϊ¼Ì³Ð¡£
´ÓÕâ¸ö½Ç¶ÈÀ´¿´¿´jsµÄ¼Ì³Ð·½Ê½¡£jsÖм̳з½Ê½ÓëдÀ෽ʽϢϢÏà¹Ø¡£²»Í¬µÄдÀ෽ʽÔì³É²»Í¬µÄ¼Ì³Ð·½Ê½¡£¸÷ÖÖÁ÷ÐÐjs¿â¼Ì³Ð·½Ê½Ò²¸÷²»Ïàͬ¡£´Ó×î¼òµ¥µÄ
¸´ÓÿªÊ¼¡£
1¡¢¹¹Ô캯ÊýдÀ࣬ͨ¹ý·½·¨µ÷Óø´ÖƸ¸ÀàÊôÐÔ¸ø×ÓÀà
ʵÏּ̳Ð
ÕâÀ︸À࣬×ÓÀ඼Óù¹Ô캯Êý·½Ê½Ð´£¬²»ÓÃÔ­ÐÍ¡£×ÓÀàµ÷Óø¸ÀຯÊýÀ´¸´ÖƸ¸ÀàµÄÊôÐÔ¡£
/**
* ¸¸ÀàPolygon:¶à±ßÐÎ
* @param {Object} sides
*/
function Polygon(sides) {
this.sides = sides;
this.setSides = function(s) {this.sides=s;}
}
/**
* ×ÓÀàTriangle:Èý½ÇÐÎ
*/
function Triangle() {
this.tempfun = Polygon;//¸¸ÀàÒýÓø³Öµ¸ø×ÓÀàµÄÒ»¸öÊôÐÔtempfun
this.tempfun(3);//µ÷ÓÃ
delete this.tempfun;//ɾ³ý¸ÃÊôÐÔ
this.getArea = function(){};
}
//new¸ö¶ÔÏó
var tri = new Triangle();
console.log(tri.sides);//¼Ì³ÐµÄÊôÐÔ
console.log(tri.setSides);//¼Ì³ÐµÄ·½·¨
console.log(tri.getArea);//×ÔÓеķ½·¨
//ȱµãÊǶÔÓÚTriangleµÄʵÀý¶ÔÏóÓÃinstanceofΪ¸¸ÀàPolygonʱÊÇfalse
console.log(tri instanceof Triangle);//true
console.log(tri instanceof Polygon);//false

ÒòΪjs¾ßÃûº¯ÊýÓÐËÄÖÖµ÷Ó÷½Ê½
£¬×ÓÀ໹¿ÉÒÔÓÐÒÔϵĶàÖÖʵÏÖ·½Ê½¡£Ö»ÊÇÔÚ×ÓÀàÖе÷Óø¸Àà·½·¨²»Í¬¶øÒÑ¡£
function Triangle() {
Polygon.call(this,3);//call·½Ê½µ÷Óø¸Àà
this.getArea = function(){};
}
function Triangle() {
Polygon.apply(this,[3]);//apply·½Ê½µ÷Óø¸Àà
this.getArea = function(){};
}
function Triangle() {
var temp = new Polygon(3);//new·½Ê½µ÷Óø¸Àà
for(atr in temp)//È«²¿¸´ÖƸø×ÓÀà
this[atr] = temp[atr];

this.getArea = function(){};
}

ÕâÖÖ·½Ê½µÄȱµãÊÇ×ÓÀàµÄʵÀý¶ÔÏóÓÃinstanceof¼ì²é¸¸Ààʱ×ÜÊÇfalse¡£ÕâÓëjavaÖм̳Ð"is a "µÄ¹ØϵÊÇÎ¥±³µÄ¡£


Ïà¹ØÎĵµ£º

Javascript ÃæÏò¶ÔÏó±à³Ì£¨Ò»£©£º·â×°


ѧϰJavascript£¬×îÄѵĵط½ÊÇʲô£¿
ÎÒ¾õµÃ£¬Object£¨¶ÔÏó£©×îÄÑ¡£ÒòΪJavascriptµÄObjectÄ£ÐͺܶÀÌØ£¬ºÍÆäËûÓïÑÔ¶¼²»Ò»Ñù£¬³õѧÕß²»ÈÝÒ×ÕÆÎÕ¡£
ÏÂÃæ¾ÍÊÇÎÒµÄѧϰ±Ê¼Ç£¬Ï£Íû¶Ô´ó¼ÒѧϰÕâ¸ö²¿·ÖÓÐËù°ïÖú¡£ÎÒÖ÷Òª²Î¿¼ÁËObject-Oriented JavaScriptºÍProfessional JavaScript for Web Developers (2nd Edition)ÕâÁ½±¾Êé¡£ ......

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......

javascript location.reload()

¹¦ÄÜ£º
ÖØмÓÔØÎĵµ¡£
Óï·¨£º
location.reload(force)
²ÎÊý£º
force£º¿ÉÑ¡²ÎÊý£¬ÊÇÒ»¸ö²¼¶ûÖµ¡£
      Èç¹ûÊ¡ÂÔ²ÎÊý£¬»òÕß²ÎÊýÊÇfalse£¬Ëü¾Í»áÓÃHTTPÍ·If-Modified-SinceÀ´¼ì²â·þÎñÆ÷ÉϵÄÎĵµÊÇ·ñÒѸı䡣Èç¹ûÎĵµÒѸÄ
±ä£¬reload()»áÔÙ´ÎÏÂÔظÃÎĵµ¡£Èç¹ûÎĵµÎ´¸Ä±ä£¬Ôò¸Ã·½·¨½«´Ó»º´æÖÐ ......

[·­Òë]High Performance JavaScript(009)

µÚÈýÕ  DOM Scripting  DOM±à³Ì
    DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......

[·­Òë]High Performance JavaScript(010)

Cloning Nodes  ½Úµã¿Ë¡
    Another way of updating page contents using DOM methods is to clone existing DOM elements instead of creating new ones—in other words, using element.cloneNode() (where element is an existing node) instead of document.createElement().
 &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ