Most simple string format utility
function format(str, ctx) {
/**
* Examples:
* format('hello, {name}', {name: 'wonder'})
* format('{0}, {1}', ['hello', 'world'])
*/
return str.replace(/\{(\w+)\}/g, function(m, p1) {
return ctx[p1];
});
}