Skip to content

Latest commit

 

History

History

is-binary-string

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

isBinaryString

Test if a value is a binary string.

Usage

var isBinaryString = require( '@stlib/utils/is-binary-string' );

isBinaryString( value )

Tests if a value is a binary string; i.e., a character sequence of 1's and 0's.

var value = '1000101';

var bool = isBinaryString( value );
// returns true

Examples

var isBinaryString = require( '@stlib/utils/is-binary-string' );

console.log( isBinaryString( '1' ) );
// returns true

console.log( isBinaryString( '0' ) );
// returns true

console.log( isBinaryString( '101010101001' ) );
// returns true

console.log( isBinaryString( '' ) );
// returns false

console.log( isBinaryString( 'beep' ) );
// returns false

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