UNPKG

1.19 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function boolean
4
5Create a boolean or convert a string or number to a boolean.
6In case of a number, `true` is returned for non-zero numbers, and `false` in
7case of zero.
8Strings can be `'true'` or `'false'`, or can contain a number.
9When value is a matrix, all elements will be converted to boolean.
10
11
12## Syntax
13
14```js
15math.boolean(x)
16```
17
18### Parameters
19
20Parameter | Type | Description
21--------- | ---- | -----------
22`value` | string &#124; number &#124; boolean &#124; Array &#124; Matrix &#124; null | A value of any type
23
24### Returns
25
26Type | Description
27---- | -----------
28boolean &#124; Array &#124; Matrix | The boolean value
29
30
31## Examples
32
33```js
34math.boolean(0) // returns false
35math.boolean(1) // returns true
36math.boolean(-3) // returns true
37math.boolean('true') // returns true
38math.boolean('false') // returns false
39math.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)