注意:a为number类型,a.toFixed(2)为string类型。
let a = 123456
console.log(a.toFixed(2),typeof(a.toFixed(2)),'ppppppppppp') //123456.00 string ppppppppppp
如果a为string类型调用toFixed(),则会报错
注意:a为number类型,a.toFixed(2)为string类型。
let a = 123456
console.log(a.toFixed(2),typeof(a.toFixed(2)),'ppppppppppp') //123456.00 string ppppppppppp
如果a为string类型调用toFixed(),则会报错