Fiveable
Fiveable

Substring

Definition

A substring refers to extracting a smaller part of a larger string by specifying its starting and ending positions.

Analogy

Imagine you have a long book, and you want to highlight only certain paragraphs or sentences that are relevant to your research. Those highlighted sections would be considered substrings because they are extracted from the original text.

Related terms

index: An index represents the position or location of each character within a string. It helps identify where specific characters are located.

charAt(): The charAt() method returns the character at a specified index within a given string.

indexOf(): The indexOf() method returns the first occurrence's index position of a specified character or substring within another string.

collegeable - rocket pep

Are you a college student?

  • Study guides for the entire semester

  • 200k practice questions

  • Glossary of 50k key terms - memorize important vocab



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.