Giter VIP home page Giter VIP logo

Comments (4)

soyaine avatar soyaine commented on June 12, 2024

@dcfm 多谢,我前天看了一些资料,也没有完全理解这两个函数的区别,所以文章里也没有深入解释。可否贴一下你这段程序的来源?

from javascript30.

 avatar commented on June 12, 2024

@soyaine 额,我也是看了相关的别人的博客之后做的笔记,好像是看了好几篇,然后总结的吧。不过 lodash 里面有这两个函数,你可以去看看源码,但是实现起来就更复杂了。我贴这个代码是因为更容易看懂 throttle 是什么功能,我觉得这思路很好。

from javascript30.

LinFeng1997 avatar LinFeng1997 commented on June 12, 2024

rxjs和红宝书都有相关的概念,防抖动就是用户在一定时间内点很多次(抖动)只取最近的,节流是一定时间内其他的都不算,只要一个。

from javascript30.

lkangd avatar lkangd commented on June 12, 2024

你这 throttle 节流的函数这么写会有细节上的问题,interval间隔越大,问题越明显。
1.第一次触发时,函数不会被执行。(解决:增加变量标记是否第一次触发)
2.若最后一次触发没有超过interval也不会触发。(解决:使用setTimeout)

from javascript30.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.