JavaScript replace() Function Example

JavaScript String replace() Function replace the string value to another value.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <title>JavaScript str.replace() function</title>
</head>
<body>
    <script type="text/javascript">
        var str="Visit to Facebook";
        document.write(str.replace("Facebook","Wikipedia"));
    </script>
</body>
</html>

Run it...   »

Example Result