Determine if a string can be converted to a number
We often use the parseint function.
However, the scope of the function is very small.
Generally, the following are similar
var mystr = "123hello";
Using parseint or isNaN (MYSTR) does not determine whether the entire string is a number.
You need to use regular expressions to do this at this time.
var pattern =/^[0-9]/;
Pattern.test (MYSTR);
static variables
One variable is common to each case object. Operate at the level of the class, not at the level of the instance.
The creation of the private static variable can be created by the way of closure;
The creation of a public static variable is much simpler, just as the property of the constructor object.
Whether it is a private static method: see if it needs to access any instance data. If it is not needed, it is more efficient to design it as a static method.
Portal
JavaScript determines if a string can be converted to a number