JS design pattern example