Skip to content

isNative

js
_.isNative(value)

检查 value 是否是原始原生函数。

¥Checks if value is a pristine native function.

注意:此方法无法在存在 core-js 包的情况下可靠地检测原生函数,因为 core-js 会绕过这种检测。尽管多次请求,但 core-js 维护者已经明确表示:任何修复检测的尝试都将受到阻碍。因此,我们别无选择,只能抛出错误。不幸的是,这也会影响依赖 core-js 的包,例如 babel-polyfill

¥Note: This method can't reliably detect native functions in the presence of the core-js package because core-js circumvents this kind of detection. Despite multiple requests, the core-js maintainer has made it clear: any attempt to fix the detection will be obstructed. As a result, we're left with little choice but to throw an error. Unfortunately, this also affects packages, like babel-polyfill, which rely on core-js.

新增于

¥Since

3.0.0

参数

¥Arguments

  1. value (*):要检查的值。

    ¥value ()*: The value to check.

返回

¥Returns

(布尔):如果 value 是原生函数,则返回 true,否则返回 false

¥(boolean): Returns true if value is a native function, else false.

示例

¥Example

js
_.isNative(Array.prototype.push);
// => true

_.isNative(_);
// => false

Lodash v4.17 中文网 - 粤ICP备13048890号