标签:struct last ice pyw prototype locale key some unshift
Array 对象是用于构造数组的全局对象,数组是类似于列表的高阶对象。
Array.prototype 属性表示Array构造函数的原型,并允许您向所有Array对象添加新的属性和方法。
Object.getOwnPropertyNames(Array) //[ "length", "name", "prototype", "isArray", "from", "of" ] Object.getOwnPropertyNames(Array.prototype) //[ "length", "constructor", "concat", "copyWithin", "fill", "find", "findIndex", "pop", "push", "reverse", "shift", "unshift", "slice", "sort", "splice", "includes", "indexOf", "keys", "entries", "forEach", "filter", "map", "every", "some", "reduce", "reduceRight", "toString", "toLocaleString", "join", "lastIndexOf", "values", "flat", "flatMap" ]
给Array对象添加新的方法
Array.prototype.duplicator = function() { let s = this.concat(this) return s }
}
let t = [1,2,3,4,5].duplicator()
console.log(t) // [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
标签:struct last ice pyw prototype locale key some unshift
原文地址:https://www.cnblogs.com/ZJTL/p/12580507.html