Note: This method is a static method on the string object, rather than an instance method:
var result = String.format("Hello {0}, the time is: {1}", "Rick",new Date().formatDate("mm-dd-yy HH:mm"));
No formatting options are supported in the format expressions and only pure string replacement is performed. So formats like {0:mm-yyyy} for a date will not work for example.
String.format(formatString)
args
Any number of arguments. Any non-string arguments are converted with .toString().