I played with the code :
<script type="text/javascript">
var str="Visit Microsoft!";
document.write(str.replace("Microsoft",function (a){return a+"1111"}));
</script>
and the answer is :
Visit Microsoft1111!
How can it be working ?
I didnt see any documented code about it .
It’s well documented, e.g. at https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace.