Skip to content

Instantly share code, notes, and snippets.

@felixrabe
Last active September 29, 2023 16:39
Show Gist options
  • Save felixrabe/db88674566e14e413c6f to your computer and use it in GitHub Desktop.
Save felixrabe/db88674566e14e413c6f to your computer and use it in GitHub Desktop.
CoffeeScript: String.startsWith() and String.endsWith()
# http://stackoverflow.com/a/646643
String::startsWith ?= (s) -> @slice(0, s.length) == s
String::endsWith ?= (s) -> s == '' or @slice(-s.length) == s
@Obiwarn
Copy link

Obiwarn commented Feb 9, 2016

Jesus. Indeed.

@Michael-F-Ellis
Copy link

Verily!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment