Created
March 12, 2014 18:01
-
-
Save uwydoc/9512532 to your computer and use it in GitHub Desktop.
Useful javascript variables and functions used frequently
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
// null function | |
var nullfn = function() {}; | |
// random number generator, within a certain range | |
var random = function(min, max) { | |
return Math.random() * (max - min) + min; | |
}; | |
var randomInt = function(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
}; | |
// current unix timestamp, unit is seconds, with precision 3 | |
var time = function() { | |
return (new Date()).getTime() / 1000; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment