pop() doesn't accept an argument in JS - Use shift() instead.