In this example we will add an anchor to a text:

<script type="text/javascript">
var txt="Hello world!"<br>document.write(txt.anchor("myanchor"))
</script>

The code above could be written in plain HTML, like this:

<a name="myanchor">Hello world!</a>