Okay I'm posting this cause I like strange code, so go easy on me...
If you absolutely do not want to create a temporary variable, global or local, and cannot use or add the forEach
function (as in patrick dw's answer), you can drag out the dreaded with
statement to do the job. It's not exactly pretty...
with(['foo', 'bar', 'wah'])
while(valueOf().length)
console.log(valueOf().shift())
Look ma, no variables!
If you are okay with using lexically scoped variables, then you can do things a bit cleaner...
with({a: ['foo', 'bar', 'wah']})
while(a.length)
console.log(a.shift())
You could do the same thing with a self-executing anonymous function, but with horrid syntax and (likely) lesser performance.
Regardless, I strongly recommend you use forEach
if you can, or just...you know, local variables.