Syntactic sugar of Math.pow
.
Math.pow(7, 3); // 343
7 *** 3 // 343
4 ** 2 // 16
const number = 5890;
number.toLocaleString('en', {style: 'currency', currency: 'GBP'} // £5,890.00
function round(number, precision) {
var shift = function (number, precision, reverseShift) {
if (reverseShift) {
precision = -precision;
}
var numArray = ("" + number).split("e");
return +(numArray[0] + "e" + (numArray[1] ? (+numArray[1] + precision) : precision));
};
return shift(Math.round(shift(number, precision, false)), precision, true);
}
+3 // 3
+'3' // 3
+true // 1
+false // 0
+null // 0
+function(val){ return val } // NaN