Navigate back to the homepage

How do you get the first letter of string Javascript?

Infinitbility
JavaScript
October 10th, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To get the first letter of a string in javascript, use string[0] instead of string use your string variable name it will return the first character of string.

Today, I’m going to show you How do I get the first letter of a string in javascript, as mentioned above, I’m going to create a sample string variable then I will use the string index method to get the first letter of the string.

Let’s start today’s tutorial on how do you get the first letter of a string in javascript.

Javascript gets the first letter of the string

Here, we will do

  1. Create a sample string variable with data.
  2. Use string index to get the first character
1// Create sample string variable with data.
2let str = "infintbility";
3
4// Use string index to get first character
5console.log("First Char: ", str[0])

Output

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How to find the first vowel in a string Javascript?

An example of making a string empty in javascript with the step-by-step guide.

October 9th, 2022 · 1 min read

How do you make a string empty in javascript?

An example of making a string empty in javascript with the step-by-step guide.

October 8th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]