Using String sup() method to coding in Javascript/JS

This JavaScript tutorial explains how to use the string approach known as sup() with syntax and examples.


In JavaScript, sup() is a string method that is used to create the HTML element. Because the sup() approach is a method of the String object, it need to be invoked through a precise instance of the String class.


In JavaScript, the syntax for the sup() technique is:


Parameters or Arguments

There are no parameters or arguments for the sup() method.


The sup() approach returns a replica of string enclosed in and tags.


The sup() approach does not trade the cost of the unique string.


Let’s take a look at an example of how to use the sup() method in JavaScript.

For example:

var totn_string = 'TechOnTheNet';


In this example, we have declared a variable referred to as totn_string that is assigned the string value of ‘TechOnTheNet’. We have then invoked the sup() technique of the totn_string variable to return a string that carries the HTML element.

We have written the output of the sup() method to the internet browser console log, for demonstration purposes, to show what the sup() technique returns.

The following will be output to the internet browser console log:


As you can see, the sup() approach created a string that contains a element. The cost of the totn_string variable (which is ‘TechOnTheNet’) is enclosed inside the and tags.