当前位置: 首页 > 图文教程 > 网络编程 > Javascript > js资料prototype 属性

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 js资料prototype 属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 125 ::
收藏到网摘: n/a

资料:prototype 属性
返回对象类型原型的引用。
objectName.prototype
objectName 参数是对象的名称。
说明
用 prototype 属性提供对象的类的一组基本功能。对象的新实例“继承”赋予该对象原型的操作。
例如,要为 Array 对象添加返回数组中最大元素值的方法。要完成这一点,声明该函数,将它加入 Array.prototype,并使用它。

复制代码 代码如下:

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 保存数组 x 中的最大值,或说 6。
所有 JScript 内部对象都有只读的 prototype 属性。可以象该例中那样为原型添加功能,但该对象不能被赋予不同的原型。然而,用户定义的对象可以被赋给新的原型。
本语言参考中每个内部对象的方法和属性列表指出哪些是对象原型的部分,哪些不是。