Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

trues

Create an array filled with true values and having a specified length.

Usage

var trues = require( '@stdlib/array/trues' );

trues( length[, dtype] )

Creates an array filled with true values and having a specified length.

var arr = trues( 2 );
// returns <BooleanArray>[ true, true ]

The function recognizes the following data types:

  • bool: boolean values.
  • generic: generic JavaScript values.

By default, the output array data type is 'bool'. To specify an alternative data type, provide a dtype argument.

var arr = trues( 2, 'generic' );
// returns [ true, true ]

Examples

var logEach = require( '@stdlib/console/log-each' );
var trues = require( '@stdlib/array/trues' );

// Create a filled array:
var x = trues( 10 );
logEach( '%s', x );