JavaScript String anchor() Method

Definition and Usage

The String anchor() method in JavaScript is deprecated.

Avoid using it.

It may stop running in your browser at any time.

anchor() The method returns the string embedded in the <a> tag:

<a name="anchorname">string</a>

Example

let text = "Hello World!";
let result = text.anchor("Chapter 10");

Try It Yourself

Syntax

string.anchor("name")

Parameters

Parameters Description
name Required. The name of the anchor.

Return Value

String embedded in the <a> tag.