• <tfoot id='Kvm5w'></tfoot>

        <bdo id='Kvm5w'></bdo><ul id='Kvm5w'></ul>

      <small id='Kvm5w'></small><noframes id='Kvm5w'>

    1. <legend id='Kvm5w'><style id='Kvm5w'><dir id='Kvm5w'><q id='Kvm5w'></q></dir></style></legend>

      1. <i id='Kvm5w'><tr id='Kvm5w'><dt id='Kvm5w'><q id='Kvm5w'><span id='Kvm5w'><b id='Kvm5w'><form id='Kvm5w'><ins id='Kvm5w'></ins><ul id='Kvm5w'></ul><sub id='Kvm5w'></sub></form><legend id='Kvm5w'></legend><bdo id='Kvm5w'><pre id='Kvm5w'><center id='Kvm5w'></center></pre></bdo></b><th id='Kvm5w'></th></span></q></dt></tr></i><div id='Kvm5w'><tfoot id='Kvm5w'></tfoot><dl id='Kvm5w'><fieldset id='Kvm5w'></fieldset></dl></div>

        我的 JavaScript 模式/实践很糟糕.我应该去哪里寻求帮助?

        时间:2024-04-19
          <bdo id='SEqd8'></bdo><ul id='SEqd8'></ul>
        • <small id='SEqd8'></small><noframes id='SEqd8'>

        • <i id='SEqd8'><tr id='SEqd8'><dt id='SEqd8'><q id='SEqd8'><span id='SEqd8'><b id='SEqd8'><form id='SEqd8'><ins id='SEqd8'></ins><ul id='SEqd8'></ul><sub id='SEqd8'></sub></form><legend id='SEqd8'></legend><bdo id='SEqd8'><pre id='SEqd8'><center id='SEqd8'></center></pre></bdo></b><th id='SEqd8'></th></span></q></dt></tr></i><div id='SEqd8'><tfoot id='SEqd8'></tfoot><dl id='SEqd8'><fieldset id='SEqd8'></fieldset></dl></div>

              <legend id='SEqd8'><style id='SEqd8'><dir id='SEqd8'><q id='SEqd8'></q></dir></style></legend>

            1. <tfoot id='SEqd8'></tfoot>
                <tbody id='SEqd8'></tbody>
                  本文介绍了我的 JavaScript 模式/实践很糟糕.我应该去哪里寻求帮助?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在过去的几年里,我几乎只专注于后端任务,我刚刚注意到,在我不在的情况下,大多数 JavaScript(和 CoffeeScript)项目都变得更漂亮了.

                  I've been working almost exclusively on back-end tasks for the past few years, and I've just noticed that most JavaScript (and CoffeeScript) projects have got a helluva lot prettier in my absence.

                  我主要在 Rails 环境中工作,几乎我所有的 JavaScript/jQuery 过去都是这样的:

                  I work primarily in a rails environment, and almost all my JavaScript/jQuery used to look like this:

                  $(an_element).an_event(function() {
                    stuff_i_want_to_do;
                  })
                  
                  $(another_element).some_other_event(function() {
                    some_other_stuff_i_want_to_do;
                  })
                  

                  除了回调,差不多就是这样.

                  Callbacks aside, that's pretty much been it.

                  无论如何,我只是浏览了一些其他人的代码,并注意到许多 javascripters 在我不在的情况下变得更漂亮了.这并不复杂,但它是我所见过的更新/更好的 JavaScript 方法的典型:

                  Anyhow, was just browsing through some other folks' code and noticed many javascripters have been getting a lot prettier in my absence. This isn't complex, but it's typical of the newer/better approach to JavaScript I've been seeing:

                  jQuery -> 
                    if $('#products').length
                      new ProductsPager()
                  
                  class ProductsPager
                    constructor: (@page = 1) ->
                      $(window).scroll(@check)
                  
                    check: =>
                      if @nearBottom()
                        @page++
                        $(window).unbind('scroll', @check)
                        $.getJSON($('#products').data('json-url'), page: @page, @render)
                  #
                  
                    nearBottom: =>
                      $(window).scrollTop() > $(document).height() - $(window).height() - 50
                  
                    render: (products) =>
                      for product in products
                        $('#products').append Mustache.to_html($('#product_template').html(), product)
                      $(window).scroll(@check) if products.length > 0
                  

                  我一直在寻找有关 JavaScript(和/或 CoffeeScript)的现代最佳实践/模式的资源,但运气不佳.所以简而言之,我应该在哪里提高速度:最好的 javascript/coffeescript 现代模式 &实践?

                  I've been looking for resources on modern best practices/patterns for JavaScript (and/or CoffeeScript), but I haven't had much luck. So in short, where should I look to be brought up to speed re: best javascript/coffeescript modern patterns & practices?

                  推荐答案

                  JavaScript 资源

                  大规模 JavaScript 应用程序架构的模式

                  面向初学者的基本 JavaScript 设计模式,第 1 卷.

                  JavaScript 模式

                  jQuery 应用程序架构工具

                  http://coffeescriptcookbook.com/chapters/design_patterns/

                  这篇关于我的 JavaScript 模式/实践很糟糕.我应该去哪里寻求帮助?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我可以从咖啡脚本文件中调用 Javascript 函数吗? 下一篇:Coffeescript --- 如何创建一个自启动的匿名函数?

                  相关文章

                  <small id='GpJp3'></small><noframes id='GpJp3'>

                      <bdo id='GpJp3'></bdo><ul id='GpJp3'></ul>
                  1. <tfoot id='GpJp3'></tfoot>

                      <i id='GpJp3'><tr id='GpJp3'><dt id='GpJp3'><q id='GpJp3'><span id='GpJp3'><b id='GpJp3'><form id='GpJp3'><ins id='GpJp3'></ins><ul id='GpJp3'></ul><sub id='GpJp3'></sub></form><legend id='GpJp3'></legend><bdo id='GpJp3'><pre id='GpJp3'><center id='GpJp3'></center></pre></bdo></b><th id='GpJp3'></th></span></q></dt></tr></i><div id='GpJp3'><tfoot id='GpJp3'></tfoot><dl id='GpJp3'><fieldset id='GpJp3'></fieldset></dl></div>
                    1. <legend id='GpJp3'><style id='GpJp3'><dir id='GpJp3'><q id='GpJp3'></q></dir></style></legend>