直接通过正则就会很准确
let data = 1.5;
let rep=/[\.]/;
console.log(rep.test(data));
当没有小数点
let data = 33;
let rep=/[\.]/;
console.log(rep.test(data));
因为是正则 所以 就算是字符串也一样有效
let data = "3.3";
let rep=/[\.]/;
console.log(rep.test(data));
直接通过正则就会很准确
let data = 1.5;
let rep=/[\.]/;
console.log(rep.test(data));
当没有小数点
let data = 33;
let rep=/[\.]/;
console.log(rep.test(data));
因为是正则 所以 就算是字符串也一样有效
let data = "3.3";
let rep=/[\.]/;
console.log(rep.test(data));