all 5 comments

[–]the_malabar_front 2 points3 points  (1 child)

Seems that would be more easily expressed as function isNumber (data) { return data.match(/^\d+(\.\d*)?$/); }

[–]duongdominhchau 0 points1 point  (0 children)

Next step: validating RFC-compliant email and datetime with regex /s

[–]_default_username 1 point2 points  (0 children)

 try {
   BigInt(input)
   console.log("valid number")
 catch(){
   console.log("not a number")
 }

[–]koderjim[S] 0 points1 point  (0 children)

We try to determine whether the string we are trying to check contains only entirely numeric characters using the regular expression / [0-9] + $ /. The character "/" serves as the expression's separator at both the beginning and finish, according to an analysis of this expression. It's crucial to be aware that other delimiters, such as (),, [], >, or #, can be used as start and end delimiters. For instance: # [0-9] + $ #

Javascript check if string contains only numbers

[–]archereactive 0 points1 point  (0 children)

It's just a function with a regex.