apply javascript patterns