Each time you click the button below, a variable i is incremented and then assigned to localStorage.x. This ultimately causes a change on the localStorage object which in turn dispatches the storage event in another window.