Explicit Casting

Unlike PHP, JavaScript has no explicit casting of types such as (int) or (float). Instead, when you need a value to be of a certain type, use one of JavaScript’s built-in functions, shown in Following Table.

Change to type Function to use
Int, Integer parseInt()
Bool, Boolean Boolean()
Float, Double, Real parseFloat()
String String()
Array split()