Parse Functions

Parse functions translate one class into another. Most parse functions, translate string into another class, such as integers or JSON structures.

parseInt(s, base)-> integer

parse a string in the given base into a 64bit integer

if base is not given, it will default to 0

if the base argument is 0, the true base is implied by the string’s prefix (if present): 2 for "0b", 8 for "0" or "0o", 16 for "0x", and 10 otherwise.

let s = 10
parseInt(s) // return the int64 value of 10
parseInt(s, 2) // return the int64 value of 2

let s = "0b10"
parseInt(s) // return the int64 value of 2

parseFloat(s)-> float

parse a string into a 64bit floating-point number

parseFloat("10") // return the float64 value of 10.0
parseFloat("10.11") // return the float64 value of 10.11

parseBool(s)

returns the boolean value represented by the string.

it accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other values returns undefined

parseBool("1") // return the bool value true  
parseBool("f") // return the bool value false  
parseBool("fa") // return undefined

parseJson(text) -> JSON

parse a JSON string

return JsonObject, JsonArray, string, float, int, bool or null value