anchor method is defined in the
String class in JS and encloses the
String instance on which it is invoked with the anchor tag (e.g.
name: a string that is to be set as the
nameattribute for the anchor tag.
nameattribute of the anchor tag is also set, as specified by the argument
let str = 'Hello World'; console.log(str.anchor('hello'));
In the example above, the
anchor method is called on an instance of
str variable. The method call results in the text stored in
str to be enclosed in the
<a> tag. Additionally, the
name argument has the value
hello, so the
name attribute of the anchor tag is also set to
View all Courses