After some string manipulation I am left with a 4 character string that I will call
varString
I need to see if this string could be interpreted as a number. I have been using
if(isNaN(Number(varString)) == false){return true}
but I am wondering if
if(Number("varString").toString() == varString){return true}
would be better.
Is one of these solutions more efficient, or more likely to catch non-numbers than the other? I have not found a difference while testing but I may have missed something. Alternative solutions welcome.
Edit in response to possible duplicate: I already have two ways of determining if something is a string or number. I am asking which method is better and why.