JavaScript splice method actually splits an array into two as shown in the below example:
var a = ['a','b','c'];
var b = a.splice(0,2);
console.log(a); // outputs ['c']
console.log(b); // outputs ['a'.'b']
Then why is it called splice since splice means to join
I'd imagine its named after RNA/DNA splicing where both addition and removal are called splicing: http://en.wikipedia.org/wiki/RNA_splicing
The splice method in JavaScript can both add and remove, so yeah.
Actually JavaScript: the first 20 years said this
1.2 [Netscape 1997c]. Most of the library additions were inspired by features available in other popular languages. The Array concat and slice methods were inspired by Python’s sequence op- erations. The Array push, pop, shift, unshift, and splice were directly modeled on like-named Perl array functions.

So it came from perl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With