Full threadokhan·Array shift is O(n). Using pop instead gives a better comparison: http://jsperf.com/while-vs-for-queue/18View on HN