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);/*ww  w .j a  va 2s  . c  om*/

Result