codes for JavascriptDesignPatterns