how javascript works behind the scenes