This is useful when you need to pass a function somewhere, but you don’t care when it runs or what it receives.
Since noop has a function signature of () => undefined, you will be warned by TypeScript if you pass it where a function is expected to return something different.
import*as
import _
_from'radashi'
import _
_.
functionnoop():undefined
export noop
A callback that does nothing and returns undefined.
@example
noop() // => undefined
noop(1) // => undefined
noop(1, 2, 3) // => undefined
@version ― 12.2.0
noop() // => undefined
FAQ
Shouldn’t I just use ?. operator?
Where possible, yes you should. The noop is best for cases where you’re not in control of the code that calls it and a function is required.