Javascript - String link() Method

The link() method is used to display a string as a hyperlink.

Description

The link() method is used to display a string as a hyperlink.

This method returns the string embedded in the <a> tag, like this:

<a href="url">string</a>

Syntax

string.link("url")

Parameter Values

Parameter Require Description
url Required. The URL to link to

Return

A string embedded in the <a> tag

Example

Display the text: "Free Web Building Tutorials!" as a hyperlink:

Demo

//display a string as a hyperlink.
var str = "Tutorials!";
var result = str.link("https://www.book2s.com");
console.log(result);/*from   www . j  a  v a  2  s  .  c  om*/

Result