Created
July 3, 2015 21:01
-
-
Save joelpalmer/7a8009494363a6930f32 to your computer and use it in GitHub Desktop.
String.toCharArray()
This file contains 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
/* Created by Joel Palmer on 7/3/2015. | |
ES6 --- FireFox 32+ only as of Created by date | |
Doc & Polyfill: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from | |
*/ | |
//create an array from function arguments | |
var args = function(){ | |
return Array.from(arguments); | |
}; | |
console.log(args(31, "Joc", "Pederson")); | |
//create an array from a string -- toCharArray() | |
String.prototype.toCharArray = function(){ | |
return Array.from(this); | |
}; | |
var text = "Dodgers"; | |
console.log(text.toCharArray()); // Array [ "D", "o", "d", "g", "e", "r", "s" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment