Skip to content

Instantly share code, notes, and snippets.

@jimfleming
Created May 26, 2010 19:34
Show Gist options
  • Save jimfleming/414939 to your computer and use it in GitHub Desktop.
Save jimfleming/414939 to your computer and use it in GitHub Desktop.
Automatically truncates a string and appends an ellipsis to the end.
function ellipsis(string, length) {
return string.length > length ? (string.substr(0, length - 3) + '...') : string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment