Debounce and Throttle in Javascript