Singletonã§å®è£ ãããè¦ä»¶ããã£ãããã°ã°ãã£ã¦ãè¯ãã®ããªãã¦æ¬èªãã§ãæ®å¿µãªãã®ãããªãã£ãã®ã§èªåã§å®è£ ãã¦ã¿ããã¡ãªã¿ã«æ¬ã¯ãJavaScriptãã¿ã¼ã³ âåªããã¢ããªã±ã¼ã·ã§ã³ã®ããã®ä½æ³ã è¦ä»¶ newã§ããªãããã«ããã åä¸ãªãã¸ã§ã¯ããè¿ãã ã¯ã©ã¹åã¯æ¬ã«ãã£ããã®ã¨åãUniverseã«ãããå¥ã«ãªãã§ãokã æåã«ãã¹ãã³ã¼ã newã§ããªãã try { new Universe() } catch(e) { console.info("ok", e); } new ãããä¾å¤ãåãããããã«ããã åä¸ãªãã¸ã§ã¯ãã var u1 = Universe.getInstance(); var u2 = Universe.getInstance(); console.info(âtrue?â, u1 === u2); console.info(âtrue
{{#tags}}- {{label}}
{{/tags}}