Record String manipulation in JavaScript

Source: Internet
Author: User

String manipulation in JS
String: The base data type, once defined, is not modified, and if modified, re-opens the space store. Strings have attribute length and a series of methods.
The generation transformation of a string (any type of data can be converted to a string)
Three ways to convert to a string:
1.. toString () method
Note: Undefined, NULL does not have the ToString () method.
Code
var num = 28;
Console.log (typeof num.tostring ());
The returned result is "string",

2. String () method
Note: Undefiend, NULL can be converted to strings by string ()

3. (A + "") stitching string
Note: All types can be converted into strings by stitching the string

Find characters by index:
1. Str.charat (index value); Result: the character of the corresponding index in the string
Compatibility: Good
Code:
var str = ' 0123ABC Hello! ‘;

Record String manipulation in JavaScript

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.