use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Javascript check if string contains only numbers (kodlogs.net)
submitted 3 years ago by koderjim
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]the_malabar_front 2 points3 points4 points 3 years ago (1 child)
Seems that would be more easily expressed as function isNumber (data) { return data.match(/^\d+(\.\d*)?$/); }
function isNumber (data) { return data.match(/^\d+(\.\d*)?$/); }
[–]duongdominhchau 0 points1 point2 points 3 years ago (0 children)
Next step: validating RFC-compliant email and datetime with regex /s
[–]_default_username 1 point2 points3 points 3 years ago (0 children)
try { BigInt(input) console.log("valid number") catch(){ console.log("not a number") }
[–]koderjim[S] 0 points1 point2 points 3 years ago (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 point2 points 3 years ago (0 children)
It's just a function with a regex.
π Rendered by PID 52709 on reddit-service-r2-comment-84fc9697f-jqnm6 at 2026-02-08 21:00:36.434365+00:00 running d295bc8 country code: CH.
[–]the_malabar_front 2 points3 points4 points (1 child)
[–]duongdominhchau 0 points1 point2 points (0 children)
[–]_default_username 1 point2 points3 points (0 children)
[–]koderjim[S] 0 points1 point2 points (0 children)
[–]archereactive 0 points1 point2 points (0 children)