isNativeFunction

Test if a value is a native function.

Native functions execute native code that is typically not written in JavaScript, but a lower-level language like C++. This includes the JavaScript built-in functions, functions implemented using Node.js C/C++ addons, and code compiled via WebAssembly.

Usage

var isNativeFunction = require( '@stdlib/assert/is-native-function' );

isNativeFunction( value )

Tests if a value is a native function.

var bool = isNativeFunction( Date );
// returns true

function beep() {
    console.log( 'beep' );
}

bool = isNativeFunction( beep );
// returns false

Examples

var isNativeFunction = require( '@stdlib/assert/is-native-function' );

var bool = isNativeFunction( Math.sqrt );
// returns true

bool = isNativeFunction( Date );
// returns true

bool = isNativeFunction( RegExp );
// returns true

bool = isNativeFunction( function foo() {} );
// returns false

bool = isNativeFunction( 'beep' );
// returns false

bool = isNativeFunction( 5 );
// returns false

bool = isNativeFunction( true );
// returns false

bool = isNativeFunction( null );
// returns false

bool = isNativeFunction( [] );
// returns false

bool = isNativeFunction( {} );
// returns false
Did you find this page helpful?