JavaScript, how does it work?