Javascript String format(param)

Description

Javascript String format(param)


String.prototype.format = function(param) {
    var formatted = this;
    for(i in param ){
        var regexp = new RegExp('\\{'+i+'\\}', 'gi');
        formatted = formatted.replace(regexp, param[i]);
    }//from ww w.j  av  a  2  s .c o m
    return formatted;
};



PreviousNext

Related