利用自定义方法显示数组中的全部数据

来源:互联网 发布:python 图论库 编辑:程序博客网 时间:2024/06/06 00:59
一 应用
利用prototype属性自定义一个方法,用于显示数组中的全部数据
 
二 代码
<script language="javascript">
Array.prototype.outAll=function()
{
for(var i=0;i<this.length;i++)
{
document.write(this[i]);
}
document.write("<br>");
}
var arr=new Array(1,2,3,4,5,6,7,8);
arr.outAll();
</script>
 
三 运行结果
12345678
0 0
原创粉丝点击