javascript的replace()第二个参数为函数时的参数:

 之前一直不了解,如果replace第二个参数为function,那么replace函数提供给function的输入参数是什么呢?
 这个函数又该如何返回?
    例如:
String.replace(regexp,function(?,?){})