Last active
October 10, 2016 12:58
-
-
Save jdx/83731268df9ec6879355ddd87f42d367 to your computer and use it in GitHub Desktop.
Split() in JS like in every other language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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