boolean.md (1189B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function boolean 4 5 Create a boolean or convert a string or number to a boolean. 6 In case of a number, `true` is returned for non-zero numbers, and `false` in 7 case of zero. 8 Strings can be `'true'` or `'false'`, or can contain a number. 9 When value is a matrix, all elements will be converted to boolean. 10 11 12 ## Syntax 13 14 ```js 15 math.boolean(x) 16 ``` 17 18 ### Parameters 19 20 Parameter | Type | Description 21 --------- | ---- | ----------- 22 `value` | string | number | boolean | Array | Matrix | null | A value of any type 23 24 ### Returns 25 26 Type | Description 27 ---- | ----------- 28 boolean | Array | Matrix | The boolean value 29 30 31 ## Examples 32 33 ```js 34 math.boolean(0) // returns false 35 math.boolean(1) // returns true 36 math.boolean(-3) // returns true 37 math.boolean('true') // returns true 38 math.boolean('false') // returns false 39 math.boolean([1, 0, 1, 1]) // returns [true, false, true, true] 40 ``` 41 42 43 ## See also 44 45 [bignumber](bignumber.md), 46 [complex](complex.md), 47 [index](index.md), 48 [matrix](matrix.md), 49 [string](string.md), 50 [unit](unit.md)