Skip to content

Instantly share code, notes, and snippets.

@blueelvis
Created November 24, 2018 20:05
Show Gist options
  • Save blueelvis/07e681a2c471eac73d39aaf416c77c57 to your computer and use it in GitHub Desktop.
Save blueelvis/07e681a2c471eac73d39aaf416c77c57 to your computer and use it in GitHub Desktop.
Use this to check if a string is really a number or not... Code is based in TypeScript
function isNumeric(x:string,base:number=10):boolean {
const parsedInt = parseInt(x,base);
if (isNaN(parsedInt)) {
return false;
} else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment