我是靠谱客的博主 复杂蚂蚁,这篇文章主要介绍使用Array的原型使对象具有length,和数组的内容,现在分享给大家,希望可以做个参考。

var elems = {
length: 0,
add: function (elem) {
Array.prototype.push.call(this, elem);
},
gather: function (id) {
this.add(document.getElementById(id));
}
};
elems.gather("first");
console.log(elems.length == 1 && elems[0].id, "Verify that we have an element in our stash");
elems.gather("second");
console.assert(elems.length == 2 && elems[1].id, "Verify the other insertion");

 

最后

以上就是复杂蚂蚁最近收集整理的关于使用Array的原型使对象具有length,和数组的内容的全部内容,更多相关使用Array内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部