javascript¼Ì³Ð·½Ê½Ö®¶þ
2¡¢ÔÐÍ·½Ê½Ð´À࣬ÔÐÍ·½Ê½¼Ì³Ð
core js×ÔÉíµÄ¶ÔÏóϵͳ¾ÍÊDzÉÓÃÔÐÍ·½Ê½(prototype based)¼Ì³ÐµÄ¡£»òÕß˵core
jsûÓвÉÓó£¼ûµÄÀà¼Ì³Ð(class
based)ϵͳ£¬¶øÊÇʹÓÃÔÐͼ̳ÐÀ´ÊµÏÖ×Ô¼ºµÄ¶ÔÏóϵͳ¡£¹¤×÷ÖÐÎÒÃÇÒ²¿ÉÒÔÓÃÔÐÍ·½Ê½À´ÊµÏּ̳У¬´úÂ븴ÓÃÒÔ¹¹½¨×Ô¼ºµÄ¹¦ÄÜÄ£¿é¡£
/**
* ¸¸ÀàPolygon:¶à±ßÐÎ
*
*/
function Polygon() {}
Polygon.prototype.sides = 0;
Polygon.prototype.setSides = function(s) {this.sides=s;}
/**
* ×ÓÀàTriangle:Èý½ÇÐÎ
*/
function Triangle() {}
Triangle.prototype = new Polygon();//¹Ø¼üÒ»¾ä
Triangle.prototype.getArea = function(){}
//new¸ö¶ÔÏó
var tri = new Triangle();
console.log(tri.sides);//¼Ì³ÐµÄÊôÐÔ
console.log(tri.setSides);//¼Ì³ÐµÄ·½·¨
console.log(tri.getArea);//×ÔÓз½·¨
//instanceof²âÊÔ
console.log(tri instanceof Triangle);//true£¬±íÃ÷¸Ã¶ÔÏóÊÇÈý½ÇÐÎ
console.log(tri instanceof Polygon);//true£¬±íÃ÷Èý½ÇÐÎÒ²ÊǶà±ßÐÎ
ËäÈ»´ÓÊä³ö¿ÉÒÔ¿´³ö×ÓÀà¼Ì³ÐÁ˸¸ÀàPolygonµÄÊôÐÔsidesºÍ·½·¨setSides£¬µ«sidesÊÇ0£¬Ôõô»áÊÇÈý½ÇÐÎÄØ¡£»¹µÃµ÷ÓÃÏÂ
tri.setSides(3)ʹ֮³ÉΪÈý½ÇÐΡ£ÕâÑùËÆºõºÜ²»·½±ã¡£²»ÄÜ´«²ÎÊý£¬¼´ÊÇÔÐÍ·½Ê½µÄȱµã¡£ÓŵãÊÇÕýÈ·µÄά»¤ÁË"is a"µÄ¹ØÏµ¡£
Ïà¹ØÎĵµ£º
±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔÀ´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷ÔÒò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......
<script>setTimeout("redirect('<?=$url_forward?>');", <?=$ms?>);</script>
ÉèÖ÷ÖÒ³£º$page $pagesize $offset = ($page-1)*$pagesize;
$limit = "limit $offset,$pagesize" ......
µÚ¶þÕ£ºECMAScript»ù´¡
1.µ±º¯ÊýÎÞÃ÷È··µ»ØÖµÊ±£¬·µ»ØµÄÒ²ÊÇÖµundefined
function testFunc(){}
alert(testFunc()==undefined);
2.typeof(null)=='object' //true,null¿ÉÒÔ½âÊÍΪ¶ÔÏóռλ·û
3.undefined ÊÇÉùÃ÷Á˱äÁ¿µ«Î´¶ÔÆä³õʼ»¯Ê±¸³Óè¸Ã±äÁ¿µÄÖµ£¬nullÔòÓÃÓÚ±íʾÉÐδ´æÔڵĶÔÏó¡£
alert(nu ......
Identifier Resolution Performance ±êʶ·ûʶ±ðÐÔÄÜ
Identifier resolution isn't free, as in fact no computer operation really is without some sort of performance overhead. The deeper into the execution context's scope chain an identifier exists, the slower it is to access for ......
Nested Members ǶÌ׳ÉÔ±
Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......