coerce.toType

This function converts a value to a specified type.

Syntax

coerce.toType(value, type)

Arguments

Argument

Type

Description

value

Any

The value to be coerced.

type

string

The data type to coerce to.

Returns

Type

Description

Any

The coerced value.

Examples

The function coerce.toType("123","int") returns 123.