Best practices for JQuery namespaces + general purpose utility functions

前端 未结 2 644
南旧
南旧 2021-01-31 23:26

What are some current \"rules of thumb\" for implementing JQuery namespaces to host general purpose utility functions?

I have a number

2条回答
  •  礼貌的吻别
    2021-02-01 00:04

    For the record, I ended up using the first syntax:

    $(function ()
    {
       //********************************
       // PREDIKT NAMESPACE
       //********************************
    
       if (typeof (Predikt) === "undefined")
       {
          Predikt = {};
       }
    
       //********************************
       // PREDIKT.TIMER NAMESPACE
       //********************************
    
       if (typeof (Predikt.Timer) === "undefined")
       {
          Predikt.Timer = {};
       }
    
       Predikt.Timer.StartTimer = function ()
       {
          return new Date().getTime();
       };
    
       Predikt.Timer.EndTimer = function ()
       {
          return new Date().getTime();
       };
    
    });
    

提交回复
热议问题