Recreate parseFloat()?
How to recreate parseFloat() from JavaScript to microScript.
Good question. In addition to that, what is the best way to convert a string that contains a number into a 'real' number?
Yes, one could loop through it and evaluate with multiple if .. then's ...
, but that would be kind of excessive ...
A parseFloat function could certainly help, I will add that to my todo list.
String and numbers in microScript actually rely a lot on the equivalent JavaScript types, thus you can use this simple hack to convert a string type to a number type:
mynumber = mystring * 1
The string will be automatically cast to a number when you try to apply an arithmetic operator to it (unless the operator is +, which also serves to concatenate strings).