prompt、tofixed方法 用户1328945930429 2021-09-01 297 阅读1分钟 prompt方法 作用:向程序输入数据 格式:prompt(‘提示文字’默认值) var res=parseTnt(prompt('请输入一位四位数:’:)) console.log(res,typeog res) tofixed方法 作用:对数据进行小位数保留 格式:数据.toFixed(小位数) 返回值:返回值为字符串类型 var num=math.PI; console.log(typeof num.toFixed(1));