Inside the String
Explore how to work with JavaScript strings by learning to initialize them in various ways and access individual characters using indexes. Understand string manipulation techniques like reversing strings, shifting characters, and checking for palindromes. This lesson guides you through hands-on exercises to practice these fundamental string operations, strengthening your programming skills in JavaScript.
Collection
A collection is a general term used to group multiple values into a single unit. We use collections all the time in the real world―a book is a collection of pages, a train is a collection of train cars, and a wardrobe is a collection of clothes.
String
A string is a collection of characters, mostly treated as a single unit. It is used to store text values like a name, address, message, etc.
Initializing the string
There are various ways to initialize a string in JavaScript. The following program demonstrates these methods:
There are a few new things that we need to understand in the code above. The following are the three ways of initializing a string variable:
Line 1: The text of
String1...