Javascript String Methods

Javascript String Methods

String is the built-in object corresponding to the primitive data type. String have a large number of methods for string manipulation and examination.

The String() constructor takes an optional argument that specifies its initial value.

Var s=new String();

Var  test=new String(“Human Nature”);

String property is length,  which indicates the number of characters in the string.

var s=”String inside the javascript”;

var strlen=s.length;

var str=”test”’;

str=str.toUpperCase();

“test”.charAt(1);

“test”.charCodeAt(1);

indexOf() method takes a string argument and returns the index of the first occurrence of the argument in the string.

Example :-

“test”.indexOf(“s”,3);

This method return 1 , if result if true. Other wise it will return -1;

String method with HTML

Javascript String Methods




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top