A function to get rid of the stupid "Math" object once and for all!
It allows this sort of syntax:
myVariable = floor(myVariable)
myOtherVariable = random()
function( | |
a, b //placeholders | |
) | |
{ | |
for(b in a = Object.getOwnPropertyNames(Math)) //for every item in the "Math" object | |
this[a[b]] = Math[a[b]] //set the global item to the math item | |
} |
function(a,b){for(b in a=Object.getOwnPropertyNames(Math))this[a[b]]=Math[a[b]]} |
{ | |
"name": "MathGlobalizr", | |
"description": "A function to get rid of the stupid Math object once and for all!", | |
"keywords": [ | |
"Math", | |
"math", | |
"global", | |
"simple", | |
"shorter" | |
] | |
} |
<!doctype html> | |
<title>Foo</title> | |
<div>Expected value: <b>25</b></div> | |
<div>Actual value: <b id=ret></b></div> | |
<script> | |
( | |
function(a,b){for(b in a=Object.getOwnPropertyNames(Math))this[a[b]]=Math[a[b]]} | |
)() | |
document.getElementById("ret").innerHTML = floor(25.64) | |
</script> |
@atk fixd!