let a = "1.23"; const checkNotInt=(a)=>{ if(a){ let str = String(a); let dot_index = str.indexOf("."); let not_int_num = str.length - (dot_index+1); if(dot_index>-1 && not_int_num>0){ console.log(`是${not_int_num}位小数`) }else{ console.log("不是小数") } } } checkNotInt(a); checkNotInt(123);