The String Type
The String type is the object representation for strings and is created using the String constructor:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var stringObject = new String("hello world");
document.writeln(stringObject);
</script>
</head>
<body>
</body>
</html>
valueOf(), toLocaleString(), and toString() - return the object's primitive string value.
We can access an individual character with bracket notation and a numeric index:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var stringValue = "hello world";
document.writeln(stringValue[1]); //"e"
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Essential Types
JavaScript Book
Essential Types
String:
- The String Type
- String length property
- String charAt()
- String charCodeAt()
- String concat()
- String slice()
- String substr()
- String substring()
- String indexOf()
- String lastIndexOf()
- String trim() Method
- String toLowerCase()
- String toLocaleLowerCase()
- String toUpperCase()
- String toLocaleUpperCase()
- String match()
- String search()
- String replace()
- String split()
- String localeCompare() Method
- String fromCharCode() Method
- String HTML Methods