Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Created November 13, 2019 07:43
Show Gist options
  • Save hoyangtsai/07d3a41f7ee6324e55b4be9b2a9eb600 to your computer and use it in GitHub Desktop.
Save hoyangtsai/07d3a41f7ee6324e55b4be9b2a9eb600 to your computer and use it in GitHub Desktop.
check a char is number between 0 and 9
let charCode = String.prototype.charCodeAt.call(str, index)
// char code between 48 and 57 is the number 0 - 9
if ( charCode < 48 || charCode > 57) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment