Posted in Javascript onJune 30, 2015
本文实例讲述了JS模式之单例模式基本用法。分享给大家供大家参考。具体如下:
//singleton var SingletonTester = (function(){ function Singleton(options){ options = options || {}; this.name = "SingletonTester"; this.pointX = options.pointX || 6; this.pointY = options.pointY || 10; }; var instance; var _static = { name : "SingletonTester", getInstance : function(options){ if(instance === undefined){ instance = new Singleton(options) }; return instance; } }; return _static; })();
希望本文所述对大家的javascript程序设计有所帮助。
JS模式之单例模式基本用法
- Author -
方方和圆圆声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@