Insert value into an array

This commit is contained in:
2019-12-22 21:16:33 +01:00
parent b68b98c948
commit 3011c25279

View 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;
}
});