I'm trying to convert a string to a float. I know that parseFloat() can do that, but I've also found the syntax below, but without much reference.
What is the correct syntax, because they all seem to work. And where can I learn more about it? I don't know how to Google it, because I don't know what it's named.
// syntax 1
alert((+"123")); // 123
alert((+"x123")); // NaN
alert((+"123x")); // NaN
alert((+"123 ")); // 123
alert((+" 123")); // 123
alert((+"12 3")); // NaN
// syntax 2
alert(+"123"); // 123
alert(+"x123"); // NaN
alert(+"123x"); // NaN
alert(+"123 "); // 123
alert(+" 123"); // 123
alert(+"12 3"); // NaN
// syntax 3
alert(+("123")); // 123
alert(+("x123")); // NaN
alert(+("123x")); // NaN
alert(+("123 ")); // 123
alert(+(" 123")); // 123
alert(+("12 3")); // NaN