learning javascript patterns