Skip to content

Instantly share code, notes, and snippets.

@hanssens
Created August 19, 2014 12:36
Show Gist options
  • Save hanssens/e0b215f381940be63a0e to your computer and use it in GitHub Desktop.
Save hanssens/e0b215f381940be63a0e to your computer and use it in GitHub Desktop.
Globals.js - Provides generic global functions, helpers and extensions.
/*
* Globals.js - Provides generic global functions, helpers and extensions.
*/
/*
* Function: isNullOrEmpty()
* @value: determines if the object is null, empty or undefined.
*/
function isNullOrEmpty(value) {
return (value == null || value == "" || value == "undefined");
}
/*
* Function: isNotNullOrEmpty()
* @value: determines if the object is not null, not empty or not undefined.
*/
function isNotNullOrEmpty(value) {
return !isNullOrEmpty(value);
}
/*
* Function: random()
* @items: accepts any collection of items
*/
function random(items) {
return items[Math.floor(Math.random() * items.length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment