JavaScript Library Design

前端 未结 2 1734
佛祖请我去吃肉
佛祖请我去吃肉 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:19

    I would recommend you to follow the Module Pattern in JavaScript instead of following JSON's pattern strictly. Your subgroup is actually referring to sub-modules. Take a look at the following excellent article:

    Ben Cherry's JavaScript Module Pattern In-Depth

    Other resources you should probably go through:

    • John Resig's Learning Advanced JavaScript
    • Seven JavaScript Things I Wish I Knew Much Earlier In My Career
    • The Seven Deadly Sins Of JavaScript Implementation

提交回复
热议问题