JavaScript Library Design

前端 未结 2 1766
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 21:52

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

I am trying to consolidate common methods into one js file so they can be reused by different scripts

2条回答
  •  没有蜡笔的小新
    2021-01-29 22:26

    There are problems with the module pattern. See http://snook.ca/archives/javascript/no-love-for-module-pattern. I used to use it before but stopped. Now I just tend to keep it simple. If you really want sub-namespacing you can make a simple namespace function for the job.

    See http://blogger.ziesemer.com/2008/05/javascript-namespace-function.html

提交回复
热议问题