Latest web development tutorials

JavaScript sub () method

String Object Reference JavaScript String Object

Definition and Usage

sub () method is used to display the string as a subscript.

The method returns a string added <sub> tag, as follows:

<Sub> string </ sub>

grammar

string.sub()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support sub () method


Examples

Examples

The string is displayed as subscript:

<script>

var str = "Hello world!";
document.write(str.sub());

</script>

try it"


String Object Reference JavaScript String Object