- ES6 - Discussion
- ES6 - Useful Resources
- ES6 - Quick Guide
- ES9 - New Features
- ES8 - New Features
- ES7 - New Features
- ES6 - Browsers
- ES6 - Image Map
- ES6 - Debugging
- ES6 - Multimedia
- ES6 - Animation
- ES6 - Validations
- ES6 - Proxy API
- ES6 - Reflect API
- ES6 - Object Extensions
- ES6 - Error Handling
- ES6 - Modules
- ES6 - Promises
- ES6 - Maps And Sets
- ES6 - Classes
- ES6 - Collections
- ES6 - Iterator
- ES6 - HTML DOM
- ES6 - RegExp
- ES6 - Math
- ES6 - Date
- ES6 - Arrays
- ES6 - New String Methods
- ES6 - Symbol
- ES6 - Strings
- ES6 - Boolean
- ES6 - Number
- ES6 - Objects
- ES6 - Page Printing
- ES6 - Void Keyword
- ES6 - Dialog Boxes
- ES6 - Page Redirect
- ES6 - Cookies
- ES6 - Events
- ES6 - Functions
- ES6 - Loops
- ES6 - Decision Making
- ES6 - Operators
- ES6 - Variables
- ES6 - Syntax
- ES6 - Environment
- ES6 - Overview
- ES6 - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ES6 - Strings
The String object lets you work with a series of characters; it wraps JavaScript’s string primitive data type with a number of helper methods.
As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.
Use the following syntax to create a String object.
var val = new String(string);
The string parameter is a series of characters that has been properly encoded. String.
String Properties
Following is a pst of the properties of String object and its description.
Sr.No | Property & Description |
---|---|
1 | Returns a reference to the String function that created the object . |
2 | Returns the length of the string. |
3 | The prototype property allows you to add properties and methods to an object . |
String Methods
Here is a pst of the methods available in String object along with their description.
Sr.No | Method & Description |
---|---|
1 | Returns the character at the specified index. |
2 | Returns a number indicating the Unicode value of the character at the given index. |
3 | Combines the text of two strings and returns a new string. |
4 | Returns the index within the calpng String object of the first occurrence of the specified value, or -1 if not found. |
5 | Returns the index within the calpng String object of the last occurrence of the specified value, or -1 if not found. |
6 | Returns a number indicating whether a reference string comes before or after or is the same as the given string in a sorted order. |
7 | match()
Used to match a regular expression against a string. |
8 | Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring. |
9 | Executes the search for a match between a regular expression and a specified string. |
10 | Extracts a section of a string and returns a new string. |
11 | Sppts a String object into an array of strings by separating the string into substrings. |
12 | Returns the characters in a string beginning at the specified location through the specified number of characters. |
13 | Returns the characters in a string between two indexes into the string. |
14 | The characters within a string are converted to lower case while respecting the current locale. |
15 | toLocaleupperCase()
The characters within a string are converted to uppercase while respecting the current locale. |
16 | Returns the calpng string value converted to lowercase. |
17 | Returns a string representing the specified object. |
18 | Returns the calpng string value converted to uppercase. |
19 | Returns the primitive value of the specified object. |