Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从字符串示例中捕获或过滤一个数字:
var Mystring = "4.0" // or sometimes 4.5
在这个例子中,我需要找到.5or.0来替换它或删除它。
.5
.0
你想截断数字吗?
Math.floor(Number("4.0"))
即使有空格它也可以工作:
Math.floor(Number(" 4.5 "))