chore(js): Declare vars only once since they're hoisted

Major issue flagged by our friends over at Scrutinizr