What exactly does the anonymous JavaScript function f => f do?

后端 未结 5 595
庸人自扰
庸人自扰 2020-12-12 16:17

I\'m using a third-party library that has a function that takes functions as arguments. I\'m doing some conditional checks to decide whether or not to add a particular funct

5条回答
  •  鱼传尺愫
    2020-12-12 16:25

    Others have already mentioned what f => f does, so I'm not going to go deeper into that. I'm just going to explain the rest of the function, because there's a bit of a difference between f => f and __DEV__ ? devTools() : f => f

    The ternary operator checks if __DEV__ is a truthy value, and if so, it return function devTools(). otherwise, it return the identity function f => f which does nothing. Put differently: this code enables some development mode functions. Without the remaining code, it's hard to tell what this mode adds, but presumably, it will enable some extra logging information and less obfuscation.

提交回复
热议问题