Instantly share code, notes, and snippets.

Embed
What would you like to do?
MathGlobalizr

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

This comment has been minimized.

atk commented Mar 28, 2012

Please correct package.json; using unescaped double quotes within a string is not a good idea.

@williammalo

This comment has been minimized.

Owner

williammalo commented Mar 28, 2012

@atk fixd!

@atk

This comment has been minimized.

atk commented Mar 28, 2012

Thank you!

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