Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created March 21, 2014 13:44
Show Gist options
  • Save james2doyle/9686574 to your computer and use it in GitHub Desktop.
Save james2doyle/9686574 to your computer and use it in GitHub Desktop.
String.prototype.supplant from Douglas Crockford's Remedial JavaScript
String.prototype.supplant = function(o) {
return this.replace(/{([^{}]*)}/g,function(a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment