/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Format a string with an array of arguments. * * @param msg A string. * @return A formatted string */ function format(msg) { if (arguments && arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { msg = msg.replace('{'+(i-1)+'}', arguments[i]); } } return msg; }
URL: http://mariuzzo.com/
Comments
