I'm trying to chain methods of an Array
object together but it won't let me.
var arr = [1,2,3];
arr.splice(-3, 1, 'foot').splice(arr.length,0, 'hand');
console.log(arr) // ['foot', 2, 3]
//trying to get ['foot', 2, 3, 'hand']
This doesn't work. I have to split up the second splice
onto a new statement. Why doesn't this work? I've seen chaining done many times in JavaScript code.