basic javascript patterns