JavaScript Library Design -


I have a general question about the design of JavaScript libraries.

I am trying to consolidate common methods in a JS file so that they can be reused by various scripts.

I have seen how the JSON library is structured and believe it was a good way. .

So they start making an example of the class:

  if (! This.JSON) {this.JSON = {}; }  

Then they do this:

  (function () {if (JSON.stringify! Type == 'type' function) {JSON .stringify = Function (value, replacer, space) { 

If you just want to JSON, then it works right. [Function_name], but what if I want a more structured library So I want to: JSON. [Subgroup]. [Function]. How do I create my JS Library like this?

Any link for resources is greatly appreciated, thanks.

I come Instead of adhering to the Poko JSON pattern strictly following the module pattern in Javascript, your subgroup is actually referring to the sub-module. See the following excellent article:

< / P>

Other resources you should probably go through:


  • Comments