jsmodern
Version:
An extension to existing JavaScript, influenced by other great languages such as Rust, Dart, Java, Golang, etc.
13 lines • 434 B
JavaScript
export const remove = {
label: 'remove',
fn: function arrayRemove(index) {
const ctx = this;
const len = ctx.length;
const indexInt = null == index ? 0 : Number(index);
if ('number' !== typeof (index) || index < 0 || index > len - 1) {
throw new TypeError(`Array index out of bound`);
}
return ctx.splice(indexInt, 1)[0];
},
};
//# sourceMappingURL=remove.js.map