typescriptno-op

TypeScript: noop => noop


I've seen the syntax noop => noop here. I was rather expecting something like () => noop to be valid. What does noop => noop stand for and when should one use this?


Solution

  • noop => noop defines a function that takes a parameter named noop and returns that parameter. It's the identity function.

    There's nothing magical about the name noop; x => x would be equivalent. () => noop is not a valid function because noop wouldn't refer to anything.