Java-esque OOP in JavaScript and a jQuery fail

前端 未结 6 1633
走了就别回头了
走了就别回头了 2021-02-08 06:31

I\'m working on a project and I\'m really trying to write object-oriented JavaScript code. I have just started reading Douglas Crockford\'s JavaScript: The Good Parts and I\'m q

6条回答
  •  隐瞒了意图╮
    2021-02-08 07:02

    If it's not a jquery plugin, I would write something like this:

        var app = {
          init: function(){
            app.SetUpElements();
          },
          SetUpElements: function() {
            return 'something';
          }, 
          etc: function() {
    
          }
        };
       $(document).ready(app.init);
    

提交回复
热议问题