Skip to content

Instantly share code, notes, and snippets.

@GianlucaGuarini
Created August 8, 2013 13:01
Show Gist options
  • Save GianlucaGuarini/6184371 to your computer and use it in GitHub Desktop.
Save GianlucaGuarini/6184371 to your computer and use it in GitHub Desktop.
Object.getOwnPropertyNames(window.Math).forEach(function (method) {
window[method] = Math[method];
});
@GianlucaGuarini
Copy link
Author

Now all the Math functions are available to the window object so you can easily use them without any prefix:
round();
floor();
abs();
and so on..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment