Whenever I use the splice method in Javascript like so:
Array.prototype.mymethod = function() {
return this[num].splice();
}
It returns an error in my tests saying that splice() is not a method in Javascript. The test only contains an array consisting of ['a', 'b', 'c'], however it’s not working when the prototype I’m using tries to splice() the array. Can’t seem to figure out what’s going on. Thanks.
this.splice()splices the arraythis[num].splice()tries to splice the element at index num which is a string and doesnt have a splice method