How to use regular expressions to detect decimals in JavaScript
Editor to share with you how to use regular expressions to detect decimals in JavaScript, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
With regular expressions, the syntax "var rep=/ [\.] /; rep.test (num)".
Function isDot (num) {var rep=/ [\.] /; if (rep.test (num)) {console.log ("is a decimal");} else {console.log ("not a decimal");}} isDot (121.121); / is a decimal isDot (454.654); / / is a decimal isDot (454654) / / not above the decimal number is all the contents of the article "how to detect decimals using regular expressions in JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!