Javascript Shift Time Complexity