const n = Math.PI,
      precision = 6function toFixed(num, fixed) {
    var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
    return num.toString().match(re)[0];
}
console.log(toFixed(n, precision))const toFixed = (n,p) => {
const nStr = `${n}`,
	number = nStr.slice(0, nStr.indexOf(".")+p+1)
return Number(number)
}
console.log(toFixed(n,precision))const limitPrecision = (n,p) => (0|n*10**p)/10**p
      
console.log(limitPrecision(n, precision))