Make Math Global
Object.getOwnPropertyNames(Math).forEach(i => window[i] = Math[i]);
// or with map, just to be shorter
Object.getOwnPropertyNames(Math).map(i => window[i] = Math[i]);
// if this points to window
Object.getOwnPropertyNames(Math).map(i => this[i] = Math[i]);
// or using the deprecated "with" statement
with (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.