Skip to content

Latest commit

 

History

History

is-primitive

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

isPrimitive

Test if a value is a JavaScript primitive.

Usage

var isPrimitive = require( '@stdlib/utils/is-primitive' );

isPrimitive( value )

Tests if a value is a JavaScript primitive.

var bool = isPrimitive( false );
// returns true

Notes

  • Six primitives:

    • string
    • number
    • boolean
    • null
    • undefined
    • symbol (ES6/ES2015)

Examples

var isPrimitive = require( '@stdlib/utils/is-primitive' );

var bool = isPrimitive( false );
// returns true

bool = isPrimitive( 0 );
// returns true

bool = isPrimitive( '' );
// returns true

bool = isPrimitive( null );
// returns true

bool = isPrimitive( undefined );
// returns true

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

bool = isPrimitive( {} );
// returns false

bool = isPrimitive( function(){} );
// returns false

bool = isPrimitive( new Boolean() );
// returns false

bool = isPrimitive( new String() );
// returns false

bool = isPrimitive( new Array() );
// returns false

bool = isPrimitive( new Object() );
// returns false