Add Array.extend prototype
This commit is contained in:
parent
c0fbfcfd6e
commit
c27266c234
1 changed files with 14 additions and 0 deletions
14
lib/utils/prototypes.js
vendored
14
lib/utils/prototypes.js
vendored
|
@ -53,6 +53,20 @@ Object.defineProperty(Array.prototype, 'map', function (fn, array) {
|
|||
return result
|
||||
})
|
||||
|
||||
Object.defineProperty(Array.prototype, 'extend', {
|
||||
value: function (obj) {
|
||||
if (Array.isArray(obj)) {
|
||||
obj.forEach(function (v) {
|
||||
if (typeof v !== 'undefined') {
|
||||
this.push(v)
|
||||
}
|
||||
}, this)
|
||||
} else {
|
||||
this.push(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Object.defineProperty(Object, 'isObject', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
|
|
Loading…
Reference in a new issue