String <[ Var ]> Table of contents
cast2type - Cast any type to any other type or return null
cast2type( value, type, noTypeConversion = true, customSplitter = null, customStrFalseValues = null ) // *Cast values from one type to another.
| Parameter | Type | Default | Description |
|---|---|---|---|
| value | * | - | Value to convert |
| type | String | - | Type to convert to |
| noTypeConversion | Boolean | true | Do not convert across types (Array,Object,String) |
| customSplitter | String | ',' | Splitter string |
| customStrFalseValues | Array | ['0','false','off',''] | String values that evaluate to false |
| Type/Value | Description |
|---|---|
| null | Empty or invalid conversion |
| any | Converted value |
cast2type('true','boolean'); // trueisEmpty - Check if a value is empty
isEmpty( value ) // booleanWill check if a value is empty, the value can be a string or object, any other type is never empty.
| Parameter | Type | Default | Description |
|---|---|---|---|
| value | * | - | Value to check |
| Type/Value | Description |
|---|---|
| boolean | True if the supplied value is empty |
isEmpty( {} ); // true
isEmpty( '' ); // true
isEmpty( [] ); // true
isEmpty( null ); // true
isEmpty( 0 ); // true
isEmpty( false ); // true
isEmpty(); // trueString <[ Var ]> Table of contents