Recently, I have been utilizing CoffeeScript in conjunction with the JS splice function. From my understanding, the JS splice function should return the objects that were spliced out and modify the original array. While this concept works smoothly with simple arrays, issues arise when adding objects to the array. Below is a simplified scenario along with comments:
Additionally, here's a helpful example code snippet
#Class that will go in array
class Thing
do: ->
alert "Hi"
a = new Thing
b = new Thing
arr = []
arr.push(a)
arr.push(b)
arr[0].do() # this works
result = arr.splice(0,1)
alert result.do() # this does not work
Could anyone shed light on why this issue occurs with the splice function? Any insights or solutions would be highly welcomed and appreciated,