JavaScript String Methods (opens in new tab)
A String in JavaScript is a sequence of characters used to store text. let course = "JavaScript"; 1. String length Purpose Returns the total number of characters in a string. Syntax string.length Example let company = "OpenAI"; console.log(company.length); Output 6 Real-Time Example Checking password length before registration. 2. String charAt() Purpose Returns the character at a specified index. Syntax string.charAt(index) Example let city = "Madurai"; console.log(city.charAt(3)); Output u ...
Read the original article