Quickly Creating an HTML Link in JavaScript

A cool and little known JavaScript function is .link() available to all string objects. Calling string.link(url) returns an HTML string for an anchor tag with the URL in it. For example:

var text = 'the best website ever';
var html = text.link('http://bencollier.net/');
html === "the best website ever" //true

A great way to quickly make links without having to do:

var text = "the best website ever";
var url = "http://bencollier.net/";
var html = "" + text +"" ;
html === "the best website ever" //true