Skip to content

Instantly share code, notes, and snippets.

@uwydoc
Created March 12, 2014 18:01
Show Gist options
  • Save uwydoc/9512532 to your computer and use it in GitHub Desktop.
Save uwydoc/9512532 to your computer and use it in GitHub Desktop.
Useful javascript variables and functions used frequently
// 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