push(undefined) has a confusing behavior
rinick opened this issue ยท 2 comments
rinick commented
Line 131 in ebe332b
in js Array you can push(undefined)
or unshift(undefined)
and it works exactly as what people expect.
in Denque, push(undefined)
is ignored and wont change the queue at all.
So if someone just replaces his Array with Denque for better performance, he might hit this hidden trap and spend hours to figure out what causes the new issues.
rinick commented
and the readme also says
If the queue is empty, undefined is returned.
If you need to differentiate between undefined values in the queue and pop() return value,
check the queue .length before popping.
Which implies undefined value is allowed in the Denque. But that's not the case