prototype ÊôÐÔÊÇ object ¹²Óеģ¬Æä×÷ÓÃÊÇ·µ»Ø¶ÔÏóÀàÐÍÔÐ͵ÄÒýÓá£Í¨³£ÎÒÃÇÓà prototype ÊôÐÔ¸ø¶ÔÏóµÄÀàµÄÀ©Õ¹Ò»×é»ù±¾¹¦ÄÜ¡£ ÕâÑù¶ÔÏóµÄÐÂʵÀý¾ÍÄÜ“¼Ì³Ð”¸³Óè¸Ã¶ÔÏóÔÐ͵IJÙ×÷¡£
±ÈÈçÏÂÃæÑùÀý¸øÊý×é¶ÔÏóÌí¼Ó·µ»ØÊý×éÖÐ×î´óÔªËØÖµµÄ·½·¨¡£
function array_max(){
var i, max = this[0];
for (i = 1; i < this.length; i++) {
if(max < this[i]) max = this[i];
}
return max;
}
Array.prototype.max = array_max;
var x = new Array(1, 2, 3, 4, 5, 6);
var y = x.max( ); //y=6
ûÓÐÁË
¡¡