replace() in JavaScript

<script language="JavaScript1.2">
    <!--
    var myString = new String("This is a test");

    var myRegExp = /is/g;

    var newString = myString.replace(myRegExp, "test");

    document.write('Notice the last name in the original string, ' + myString);

    document.write(', was replaced and is now '+ newString);

    document.close();

    -->

    </script>