Proficient in Javascript series data type string _ javascript skills

Source: Internet
Author: User
The following describes how a String consists of zero or multiple characters. Characters can contain letters, numbers, punctuation marks, and spaces. Js has nine data types: undefined, null, boolean, string, and number), object, reference, and completion ). The last three data types only serve as the intermediate result of JS running, so they cannot be used in the Code. The following describes the String:
A string consists of zero or multiple characters. Characters can contain letters, numbers, punctuation marks, and spaces. Word

The string must be enclosed in single or double quotation marks:
--------------------------------
For example, var a = 'shingbi little C ';
Var a = "shingpen small c ";
--------------------------------
Single quotation marks and double quotation marks can be used at will. However, if a string contains double quotation marks, the entire character should be

Put strings in single quotes;
A string has the length attribute and returns the number of characters in the string.
---------------------------------
Example:
Var a = "hell world ";
Alert (a. length );
Result: 11;
---------------------------------
The Slice, substring, and substr methods take a substring from the string, where

Slice and substring both accept two parameters, which are the start position and end position of the sub-string respectively.

Sub-string, excluding the character at the ending position. If the 2nd parameters are not set

Position to the end of the string.
Example:
Use Slice and substring to retrieve the string:

The Code is as follows:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.