Skip to content

Instantly share code, notes, and snippets.

@jtenner
Created November 4, 2013 18:49
Show Gist options
  • Save jtenner/7307358 to your computer and use it in GitHub Desktop.
Save jtenner/7307358 to your computer and use it in GitHub Desktop.
Cross prototype example
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