Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use javascript indexOf to find character position

Shulou Source: shulou.com Published: 2022-05-31 10:51:31 10月06日 Update

This article mainly explains "how to use javascript indexOf to find character positions", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use javascript indexOf to find character positions" bar!

Description

1. It is used to find the character position that appears for the first time. If you find it, you will return the index value. If you can't find it, it will be-1.

2. The indexOf () method is case sensitive. The first parameter is the specified character value, and the second parameter is the position from which to start. The default is 0.

Grammar

StringObject.indexOf (substring, startpos)

Example

Let str = 'abcde';let re = str.indexOf (' b'); / / let re = str.lastIndexOf ('b'); console.log (re); / / output 1 Thank you for reading, the above is the content of "how to find character positions with javascript indexOf". After the study of this article, I believe you have a deeper understanding of how to use javascript indexOf to find character positions, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Characters positions learning content parameters that is bits sizes examples ideas situations articles methods more knowledge knowledge points articles indexes grammar follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Huawei NVidia MySQL