string - Best way to check if a character is a number of letter in javascript? -


in javascript whats best way check if character (length 1), number (i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) or letter (i.e. z, z)?

thanks

i wrote little test case you, @ least numeric checking function.

considering fact functions returns true either numberic 1 or string '1' literal, using array seems fastest way (at least in chrome).

var isnumericchar = (function () {     var arr = array.apply(null, array(10)).map(function () { return true; });     return function (char) { return !!arr[char]; }; })(); 

however, if accept might return false 1, switch statement faster.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -