Skip to content

Instantly share code, notes, and snippets.

@DavidBruant
Created August 22, 2014 12:13
Show Gist options
  • Save DavidBruant/6bb76afc0e2bbfca0edb to your computer and use it in GitHub Desktop.
Save DavidBruant/6bb76afc0e2bbfca0edb to your computer and use it in GitHub Desktop.
Destructured Math
var decls = Object.getOwnPropertyNames(Math).map(function(k){
return k+" = Math."+k;
}).join(',\n');
console.log("var "+decls+';');
var toSource = Math.toSource,
abs = Math.abs,
acos = Math.acos,
asin = Math.asin,
atan = Math.atan,
atan2 = Math.atan2,
ceil = Math.ceil,
clz32 = Math.clz32,
cos = Math.cos,
exp = Math.exp,
floor = Math.floor,
imul = Math.imul,
fround = Math.fround,
log = Math.log,
max = Math.max,
min = Math.min,
pow = Math.pow,
random = Math.random,
round = Math.round,
sin = Math.sin,
sqrt = Math.sqrt,
tan = Math.tan,
log10 = Math.log10,
log2 = Math.log2,
log1p = Math.log1p,
expm1 = Math.expm1,
cosh = Math.cosh,
sinh = Math.sinh,
tanh = Math.tanh,
acosh = Math.acosh,
asinh = Math.asinh,
atanh = Math.atanh,
hypot = Math.hypot,
trunc = Math.trunc,
sign = Math.sign,
cbrt = Math.cbrt,
E = Math.E,
LOG2E = Math.LOG2E,
LOG10E = Math.LOG10E,
LN2 = Math.LN2,
LN10 = Math.LN10,
PI = Math.PI,
SQRT2 = Math.SQRT2,
SQRT1_2 = Math.SQRT1_2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment