Advertisement
Guest User

Untitled

a guest
May 30th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. String.format = function (formatString) {
  3.     if (!formatString)
  4.         return '';
  5.  
  6.     var args = Array.prototype.slice.call(arguments, 1);
  7.     return formatString.replace(/{(\d+)}/g, function (match, index) {
  8.         return args[index] ? args[index] : match;
  9.     });
  10. };
  11.  
  12. console.format = function() {
  13.     console.log(String.format.apply(this, arguments));
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement