Methods
(inner) convertToStrBool(val) → {String}
- Description:
Converts a value to a boolean as a string.
- Source:
Example
convertToStrBool(true)
// Returns 'true'
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to convert to string boolean |
Returns:
'true' || 'false' based on passed in value
- Type
- String
(inner) isBool(val) → {Boolean}
- Description:
Checks is value is a boolean.
- Source:
Examples
isBool([1,2,3])
// Returns false
isBool(true)
// Returns true
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to check if is a number |
Returns:
True if val is a boolean
- Type
- Boolean
(inner) isStrBool(val) → {Boolean}
- Description:
Checks is value is a boolean as a string.
- Source:
Examples
isStrBool("true")
// Returns true
isStrBool(true)
// Returns false
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to check if boolean as a string |
Returns:
True if val is a string boolean
- Type
- Boolean
(inner) softFalsy(val) → {Boolean}
- Description:
Checks if a value is falsy, excluding empty string and 0.
- Source:
Examples
softFalsy('')
// Returns true
softFalsy(0)
// Returns true
softFalsy(null)
// Returns false
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to check |
Returns:
- True if val is truthy, an empty string or 0
- Type
- Boolean
(inner) toBool(val) → {Boolean}
- Description:
Converts a value to a boolean.
- Source:
Examples
toBool(null)
// Returns false
toBool('false')
// Returns false
toBool('true')
// Returns true
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to convert |
Returns:
true or false based on passed in value.
- Type
- Boolean