Javascript String interpolate(props)

Description

Javascript String interpolate(props)


String.prototype.interpolate = function(props) {
  return this.replace(/\{\{(\w+)\}\}/g, function(match, expr) {
      return (props || window)[expr];
  });/*w  ww.  j a v  a  2 s.  c  o  m*/
};



PreviousNext

Related