Skip to content

Instantly share code, notes, and snippets.

@jdx
Last active October 10, 2016 12:58
Show Gist options
  • Select an option

  • Save jdx/83731268df9ec6879355ddd87f42d367 to your computer and use it in GitHub Desktop.

Select an option

Save jdx/83731268df9ec6879355ddd87f42d367 to your computer and use it in GitHub Desktop.
Split() in JS like in every other language
let splitOnce = (str, c) => {
let [a, ...b] = key.split(c)
return [a, b.join(c)]
}
let [a, b] = splitOnce('foo=bar=baz', '=')
// a === foo
// b === bar=baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment