0% found this document useful (0 votes)
21 views14 pages

JavaScript String Methods Explained

The document provides an overview of JavaScript strings and various string methods, including how to create strings, measure their length, convert cases, and manipulate them through methods like charAt, indexOf, slice, and replace. It also introduces template literals for embedding variables and multiline strings. Additionally, it suggests practice tasks for applying string manipulation skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

JavaScript String Methods Explained

The document provides an overview of JavaScript strings and various string methods, including how to create strings, measure their length, convert cases, and manipulate them through methods like charAt, indexOf, slice, and replace. It also introduces template literals for embedding variables and multiline strings. Additionally, it suggests practice tasks for applying string manipulation skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

JavaScript Strings and String

Methods
• A string is a sequence of
characters.

• It can be enclosed in single (' '),


double (" "), or backticks (` `).
What is a
• Example:
String?
Returns the number of
characters in a string.

length • Example:
Converts string to
upper or lower case.

toUpperCase() /
toLowerCase()
• Example:
Returns the character
at a specific position.

charAt(index) • Example:
Finds the position of
the first match.

indexOf • Example:
(substring)
Extracts part of a
string.

slice(start, • Example:
end)
Similar to slice but doesn't
accept negative indexes

substring(star • Example:
t, end)
Replaces the first
matched string.

replace(searc
h, • Example:
replacement)
Checks if a string
contains a substring.

includes(subst • Example:
ring)
Splits string into an array
based on a separator.

split(separato • Example:
r)
Removes white spaces
from both ends of a string.

• Example:
trim()
Allows embedded variables
BONUS: and multiline strings.
Template
Literals (` • Example:
backticks)
Practice Tasks
• Get the first and last character of a string.
• Count how many times a word appears in a
sentence.
• Check if a string is a palindrome.
• Validate a user input field (trim, length).
• Highlight keywords in a paragraph.
• Reverse a Sentence
• Capitalize Each Word in a Sentence

You might also like