A String is simply a collection of characters (letters, numbers, spaces, or symbols) wrapped inside quotation marks. In JavaScript, we can use single quotes ('...'), double quotes ("..."), or backticks (`...`) to create a string.
Concatenation means joining two or more strings together to form a single string. Traditionally, this is done using the plus sign (+) operator.
Template Literals are a modern, cleaner way to build strings using backticks (`...`) instead of quotes. Instead of using the + operator, We can inject variables directly into the string using the ${variable} syntax.
The .length property counts the total number of characters inside a string, including letters, numbers, symbols, and spaces. It is a property, not a method, so it does not use parentheses ().
Character access allows you to grab a single character from a string based on its position, known as its index. In JavaScript, tracking always starts at index 0 (the first character)..
The .trim() method removes whitespace from both ends of a string.
The .toUpperCase() method converts a string to uppercase, while the .toLowerCase() method converts it to lowercase.
These tools help you search a string to see if a specific letter or word exists inside it.
♦ .includes() answers with a simple True or False.
♦ Use .includes() when you just want a clean true or false answer to check if a word exists.
♦ .indexOf() returns the exact starting position number (index) where the word begins. If it cannot find the word, it returns -1.
♦ Use .indexOf() when you need the exact position number of a word.
The .slice(start, end) method cuts out a piece of a string and returns it as a new string..
The .replace() method finds a specific word or character inside a string and swaps it out for a new value. Standard .replace() only changes the very first match it finds, while .replaceAll() updates every single match across the entire string..
The .split() method splits a string into an array of substrings based on a specified separator.
♦ .split() moves data from a String ➡️ Array (Cuts it up).
The .join() method joins all elements of an array into a string, with an optional separator.
♦ .join() moves data from an Array ➡️ String (Glues it together).