Last active
December 16, 2015 11:09
-
-
Save ryasmi/5425568 to your computer and use it in GitHub Desktop.
Turns a string into an array.
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
// Using func. https://gist.github.com/ryansmith94/5564105 | |
func("toArray", function (elemDelimeter, attrDelimeter, fn) { | |
var i, elemArray, len; | |
elemArray = this.split(elemDelimeter); | |
len = elemArray.length; | |
for (i = 0; i < len; i += 1) { | |
elemArray[i] = elemArray[i].split(attrDelimeter); | |
if (fn) { | |
elemArray[i] = fn(elemArray[i]); | |
} | |
} | |
return elemArray; | |
}, String.prototype); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment