A. String: Stores a string and provides the properties and methods needed to handle the string.
1. Create a String object: Display and implicit
* Explicitly and implicitly declaring a string object, the type is different: an implicitly declared string object, the type is string, and the explicitly declared string object, the type is object.
* Explicit and implicit creation of strings the real difference is that if you want to reuse the same string, explicitly create the string, there is a higher efficiency;
* Create strings explicitly and also help the JavaScript interpreter to confuse numbers and strings;
2. Methods for using a String object
String object, there are many ways to discuss only two. IndexOf () and substring () method, note case.
* What you need to know: JavaScript strings, which are made up of characters. Each of these characters has an index. This index starts at 0, so the index for the first position is 0; the second is 1, and so on.
* Method IndexOf () finds and returns the index position at which the substring originated, returns 1 if the element found does not exist, or returns the index where the character is located. (LastIndexOf returns the position where the substring ends)
Here is an example of whether to include the @ symbol in an email address that determines the number of users entered:
The substring () method intercepts a string from another string using the index of the starting and ending positions of the string as arguments. You can return all the strings from the first index to the end of the string without using the second argument. For example, we want to intercept all characters from the third to the sixth character, which can be written like this:
The above mentioned is the entire content of this article, I hope you can enjoy.