Skip to content

Instantly share code, notes, and snippets.

@Quby
Created March 20, 2011 06:30
Show Gist options
  • Save Quby/878160 to your computer and use it in GitHub Desktop.
Save Quby/878160 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,str='';
for(i in words){
str += ' ' + (words[i][0] == '%'?values[words[i].slice(1)]:words[i])
}
return str;
}
//UglifyJS
String.prototype.format=function(){var a=this.split(" "),b=arguments,c=typeof b[0]=="object"?b[0]:b,d,e="";for(d in a)e+=" "+(a[d][0]=="%"?c[a[d].slice(1)]:a[d]);return e}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment