The isNative
function from the Lodash library can be a useful utility for checking whether a given value is a native function. Here's an example of how to use it:
index.tsx161 chars9 lines
In this example, we import the Lodash library using require
and define a simple function foo
. We can then use _.isNative()
to check whether Array.prototype.push
is a native function (which it is) and whether foo
is a native function (which it is not).
Note that isNative
relies on certain browser-specific behavior, so it's not guaranteed to be completely reliable in all situations. However, it can be a useful tool for type checking in many cases.
gistlibby LogSnag