Javascript use detailed explanation