You still repeat what it 'should' do. 'should' according to your assumptions which you found to be incorrect already in your first test? Maybe javascript works like you say when it is running as part of webpage/DOM rendering but there is no reason espruino on some device would work in same way.
But anyway, unless your code is part of already defined function, you are entering it line by line so it is evaluated line by (syntactically complete) line.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
You still repeat what it 'should' do. 'should' according to your assumptions which you found to be incorrect already in your first test? Maybe javascript works like you say when it is running as part of webpage/DOM rendering but there is no reason espruino on some device would work in same way.
But anyway, unless your code is part of already defined function, you are entering it line by line so it is evaluated line by (syntactically complete) line.