Skip to content

Latest commit

 

History

History

is-string

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

isString

Test if a value is a string.

Usage

var isString = require( '@stdlib/utils/is-string' );

isString( value )

Tests if a value is a string.

var bool = isString( 'beep' );
// returns true

bool = isString( new String( 'beep' ) );
// returns true

isString.isPrimitive( value )

Tests if a value is a primitive string.

var bool = isString.isPrimitive( 'beep' );
// returns true

bool = isString.isPrimitive( new String( 'boop' ) );
// returns false

isString.isObject( value )

Tests if a value is a String object.

var bool = isString.isObject( 'beep' );
// returns false

bool = isString.isObject( new String( 'boop' ) );
// returns true

isString.isStringArray( value )

Tests if a value is a string array.

var bool = isString.isStringArray( [ 'beep', new String('boop') ] );
// returns true

bool = isString.isStringArray( [ 'beep', null ] );
// returns false

isString.isPrimitiveStringArray( value )

Tests if a value is a primitive string array.

var bool = isString.isPrimitiveStringArray( [ 'beep', 'boop' ] );
// returns true

bool = isString.isPrimitiveStringArray( [ 'beep', new String('boop') ] );
// returns false

Examples

var isString = require( '@stdlib/utils/is-string' );

console.log( isString( 'beep' ) );
// returns true

console.log( isString( new String( 'beep' ) ) );
// returns true

console.log( isString( 5 ) );
// returns false

console.log( isString( null ) );
// returns false

console.log( isString( undefined ) );
// returns false

console.log( isString( {} ) );
// returns false

console.log( isString( [] ) );
// returns false

console.log( isString( function foo(){} ) );
// returns false