Skip to content

Instantly share code, notes, and snippets.

@stefanwalther
Created November 18, 2013 16:50
Show Gist options
  • Save stefanwalther/7531161 to your computer and use it in GitHub Desktop.
Save stefanwalther/7531161 to your computer and use it in GitHub Desktop.
A collection of useful JavaScript string extensions.
// ------------------------------------------------------------------
// General Utils
// ------------------------------------------------------------------
function nullOrEmpty(obj) {
if (obj == null || obj.length == 0 || obj == 'undefined') {
return true;
}
return false;
}
// ------------------------------------------------------------------
// String Extensions
// ------------------------------------------------------------------
String.prototype.startsWith = function (s) {
return (this.indexOf(s) == 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment