Actually, array.shift() returns null instead of undefined if the array was empty.