Javascript common method