Javascript String fill(o)

Description

Javascript String fill(o)


String.prototype.fill = function (o) {
    return this.replace(/{([^{}]*)}/g,
        function (a, b) {
            var r = o[b];
            return typeof r === 'string' || typeof r === 'number' ? r : a;
        }/*from w  w  w .j  a v a2s. c  om*/
    );
};



PreviousNext

Related