Insert value into an array
This commit is contained in:
9
insert-value-into-an-array/index.js
Normal file
9
insert-value-into-an-array/index.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// https://www.codewars.com/kata/insert-value-into-an-array/javascript
|
||||||
|
|
||||||
|
Object.defineProperty(Array.prototype, 'insert', {
|
||||||
|
enumerable: false,
|
||||||
|
value: function(idx, val) {
|
||||||
|
this.splice(idx, 0, val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user