-1

I'm trying to implement debounce from underscore library within setTimeout.

setInterval(function() {
  setTimeout(function(){   
    _.debounce(function() {
      console.log('debounce');
    }, 500);
  }, 1000);
}, 100);

Basically, console.log('debounce') should be called once in 500ms but it seems there's no output at all in the console.

JS Bin for testing: http://jsbin.com/beqisuruwu/edit?js,output

Thanks in advance.

RubyCat
  • 135
  • 10

1 Answers1

0

Are you sure you need function after setTimeout? Because _.debounce is a function itself. I am not sure either )) but code below works for me:setInterval(function() { setTimeout( _.debounce(function() { console.log('debounce'); }, 500) , 1000); }, 100);

AlBears
  • 1
  • 1