@stdlib/assert-is-native-function v0.2.2
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.
Installation
npm install @stdlib/assert-is-native-function
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
See Also
@stdlib/assert-is-function
: test if a value is a function.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.