Raise 10 to a power in javascript, are there better ways than this

In ES5 and earlier, use Math.pow:

var result = Math.pow(10, precision);

var precision = 5;
var result = Math.pow(10, precision);
console.log(result);

In ES2016 and later, use the exponentiation operator:

let result = 10 ** precision;

let precision = 5;
let result = 10 ** precision;
console.log(result);

if all you need to do is raise 10 to different powers, or any base to any power why not use the built in Math.pow(10,power); unless you have soe specific need to reason to reinvent the wheel


Why not:

function precision(x) {  
  return Math.pow(10, x);
}