Skip to content

Instantly share code, notes, and snippets.

@Quby
Created March 20, 2011 06:01
Show Gist options
  • Save Quby/878142 to your computer and use it in GitHub Desktop.
Save Quby/878142 to your computer and use it in GitHub Desktop.
String.prototype.format = function(){
var words = this.split(' '),
arg = arguments,
values = typeof arg[0]=='object'?arg[0]:arg,i;
for(i in words){
if(words[i][0] == '%')words[i] = values[words[i].slice(1)];
}
return words.join(' ');
}
//Compressed by UglifyJS
String.prototype.format=function(){var a=this.split(" "),b=arguments,c=typeof b[0]=="object"?b[0]:b,d;for(d in a)a[d][0]=="%"&&(a[d]=c[a[d].slice(1)]);return a.join(" ")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment