Understanding JavaScript reference versus instance