An intuitive state transition system for JavaScript