Created
May 27, 2011 04:46
-
-
Save dalmaer/994655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use ~ with indexOf to test presence | |
hasAnF="This sentence has an f.".indexOf("f")>=0 // before | |
hasAnF=~"This sentence has an f.".indexOf("f") // after | |
// Both of these operator combos will floor numbers (note that since ~ has lower precedence than |, they are not identical). | |
rand10=Math.floor(Math.random()*10) // before | |
rand10=0|Math.random()*10 // after | |
// This is equivalent to A*Math.pow(10,B). | |
million=1000000 // before | |
million=1e6 // after | |
// Did you know that strings have a .link() method? | |
html="<a href='"+url+"'>"+text+"</a>" // before | |
html=text.link(url) // after |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment