function Coll(items) {
this.removeItem = items.pop
}
const coll = new Coll([2,4,6,8,10])
console.log(coll.removeItem())
If I make console.log(coll)
, I can see that there's a function inside of the object. If I call it, it retuns undefined. I know the solution to make it run properly is to add
() => items.pop()
but I still can't understand why. The main question here is what happens when I add the () => ...()
to the method call