Summary of several commonly used string methods in JavaScript (must-read for beginners)

Summary of several commonly used string methods in JavaScript (must-read for beginners)

Several commonly used string methods in JavaScript

String is a read-only data.

Several commonly used string methods:

1. charAt: Get the corresponding character according to the specified subscript;


2. charCodeAt: Get the Asker code corresponding to the character according to the specified subscript; (there is an ASCII comparison table at the bottom)


ps: Get the characters through the Ask code;


3. substring: intercept the string;


4. substr: intercept string;


5. slice: intercept the string;


6. indexOf: Find the first occurrence of a character/substring in a large string. If found, return the index. If not found, return -1.


7. lastIndexOf: Find the last occurrence of a character/substring in a large string


8. split: split a string into an array using the specified delimiter;


9. replace: replace a character/string in a string;


10. toupperCase is uppercase, tolowerCase is lowercase


11. trim: remove the blank characters on both sides of the string;


ACSII comparison table:


Summarize

This concludes this article on the summary of several commonly used string methods in JavaScript. For more relevant JavaScript string method content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Summary of 28 common JavaScript string methods and usage tips
  • Java method to convert Date type field into json string
  • Three Ways to Find the Longest Word in a String in JavaScript (Recommended)
  • A simple way to convert JavaScript strings to numbers
  • Summary of Common Operation Methods of JavaScript String Processing
  • Detailed explanation of Javascript string methods

<<:  MySQL 4G memory server configuration optimization

>>:  How to build docker+jenkins+node.js automated deployment environment from scratch

Recommend

Details on macrotasks and microtasks in JavaScript

Table of contents 1. What are microtasks? 2. What...

Complete steps to install boost library under linux

Preface The Boost library is a portable, source-c...

Detailed explanation of tinyMCE usage and experience

Detailed explanation of tinyMCE usage initializat...

MySQL 5.6.22 installation and configuration method graphic tutorial

This tutorial shares the specific code of MySQL5....

A simple way to build a Docker environment

First, let’s understand what Docker is? Docker is...

Examples of MySQL and Python interaction

Table of contents 1. Prepare data Create a data t...

How to completely delete and uninstall MySQL in Windows 10

Preface This article introduces a tutorial on how...

Solution to the problem of failure to insert emoji expressions into MySQL

Preface I always thought that UTF-8 was a univers...

Why MySQL chooses Repeatable Read as the default isolation level

Table of contents Oracle Isolation Levels MySQL I...

JavaScript source code for Elimination

JavaScript to achieve the source code download ad...

Open the Windows server port (take port 8080 as an example)

What is a Port? The ports we usually refer to are...

Some questions about hyperlinks

<br />I am very happy to participate in this...

Advanced Usage Examples of mv Command in Linux

Preface The mv command is the abbreviation of mov...

The perfect solution to the Chinese garbled characters in mysql6.x under win7

1. Stop the MySQL service in the command line: ne...