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

Several reasons for not compressing HTML

The reason is simple: In HTML documents, multiple ...

Steps for IDEA to integrate Docker to achieve remote deployment

1. Enable remote access to the docker server Log ...

W3C Tutorial (5): W3C XML Activities

XML is designed to describe, store, transmit and ...

Detailed explanation of JavaScript animation function encapsulation

Table of contents 1. Principle of animation funct...

Simple implementation method of Linux process monitoring and automatic restart

Purpose: Under Linux, the server program may be d...

MySQL 8.0.11 MSI version installation and configuration graphic tutorial

This article shares the installation and configur...

Basic principles of MySQL scalable design

Table of contents Preface 1. What is scalability?...

Tomcat class loader implementation method and example code

Tomcat defines multiple ClassLoaders internally s...

A very detailed summary of communication between Vue components

Table of contents Preface 1. Props, $emit one-way...

How to install MySQL 8.0.17 and configure remote access

1. Preparation before installation Check the data...

Detailed usage of Linux text search command find

The find command is mainly used to find directori...

The scroll bar position is retained when scrolling the vant list component

The scroll bar position is retained when scrollin...

MySQL database basic syntax and operation

MySQL database basic syntax DDL Operations Create...

Use the more, less, and cat commands in Linux to view file contents

In Linux, the commands cat, more, and less can al...