zzl00770

导航

2024年7月27日 #

将小数转换为整数

摘要: let num = 3.14; // 向下取整let floorNum = Math.floor(num); // 结果为 3console.log("向下取整:", floorNum); // 向上取整let ceilNum = Math.ceil(num); // 结果为 4console.lo 阅读全文

posted @ 2024-07-27 12:02 品味人生nuiapp 阅读(49) 评论(0) 推荐(0) 编辑

js 判断字符串是不是数字

摘要: function isNumeric(str) { return /^\d+$/.test(str); } // 使用示例 console.log(isNumeric("123")); // 输出: true console.log(isNumeric("abc")); // 输出: false 阅读全文

posted @ 2024-07-27 12:00 品味人生nuiapp 阅读(9) 评论(0) 推荐(0) 编辑