Javascript - String sub() Method

The sub() method displays a string as subscript text.

Description

The sub() method displays a string as subscript text.

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

<sub>string</sub>

Syntax

string.sub()

Parameters

None

Return

A string embedded in the <sub> tag

Example

Display a string as subscript text:

Demo

//display a string as subscript text.
var str = "Hello World!";
var result = str.sub();
console.log(result);// w  w  w.j av a2  s  . com

Result