Make Math Global
Object.getOwnPropertyNames(Math).forEach(i => window[i] = Math[i]);
// or with map, just to be shorterObject.getOwnPropertyNames(Math).map(i => window[i] = Math[i]);
// if this points to windowObject.getOwnPropertyNames(Math).map(i => this[i] = Math[i]);
// or using the deprecated "with" statementwith (Math) {
console.log(PI, E, SQRT2, cos(1));
}
While not very useful, I sometimes like to make the entire Math object global on the window – just when speed coding and playing around.