sub()

The sub() method will convert the string value to an instance of the HTML SUB tag. That is, the string will be displayed by the browser as if it were enclosed within the opening and closing SUB tags. SUB stands for SubScript, and is used to display text which will appear slightly below the bottom edge of the surrounding, normal text.

syntax:

string.sub()

EXAMPLE

subString = new String("3");

document.write("The log is 10" + subString.sub() );

The example shows the creation of a new string, subString. It is then used within a document.write statement along with the sub() method to display the "-3" value of subString in a SubScripted version of the chosen font. The output should look as follows:



The log is 103