Created
November 4, 2013 18:49
-
-
Save jtenner/7307358 to your computer and use it in GitHub Desktop.
Cross prototype example
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
var arrayObject = ["What", "is", "going", 0,"on", 111,"..", "here"]; | |
String.prototype.slice.call(arrayObject); | |
//"What,is,going,0,on,111,..,here" | |
String.prototype.concat.call(arrayObject); | |
//"What,is,going,0,on,111,..,here" | |
String.prototype.substring.call(arrayObject,1,10) | |
//"hat,is,go" | |
String.prototype.indexOf.call(arrayObject, "n,111") | |
//17 | |
var stringObject = "Hello"; | |
Array.prototype.forEach.call(stringObject, function(item){console.log(item)}) | |
//H | |
//e | |
//l | |
//l | |
//o | |
Array.prototype.map.call(stringObject, function(item){ | |
if( item >= "A" && item <= "Z") | |
return"U"; | |
return "L" | |
}) | |
//["U", "L", "L", "L", "L"] | |
//Upper and lowercase map for the string! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment