Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • TypeScript Tutorial
  • TS Exercise
  • TS Interview Questions
  • TS Cheat Sheet
  • TS Array
  • TS String
  • TS Object
  • TS Operators
  • TS Projects
  • TS Union Types
  • TS Function
  • TS Class
  • TS Generic
Open In App
Next Article:
How to Declare an Array of Strings in TypeScript ?
Next article icon

Delete First Character of a String in TypeScript

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Deleting the first character of a string in Typescript consists of removing the character at the 0th index of the string. Using various inbuilt methods, we can extract the first character of the input string and print or return only the remaining characters apart from the first character.

There are many ways to delete the first character of the string in typescript which are as follows:

Table of Content

  • Using slice() method
  • Using substring() method
  • Using array destructing
  • Using replace() method

Using slice() method

The slice() method extracts the part of the input string and returns the extracted part in the new string. If we remove the string's first character, it can be done by mentioning the start index from which we want to extract the string.

Syntax:

string.slice(startingindex, endingindex);

Example: In the below example, we have passed the start index as 1 in slice(1). This extracts the string except the first character.

JavaScript
let input: string = "GeeksforGeeks"; let output: string = input.slice(1); console.log(output); 

Output:

eeksforGeeks

Using substring() method

The substring() method returns the part of the given string from the start index to the end index provided as the argument.

Syntax:

str.substring(startIndex, endIndex);

Example: To demonstrate extracting the string except the first character from the string which we passed as the start index as 1 in the substring(1) method.

JavaScript
let input: string = "GeeksforGeeks"; let output: string = input.substring(1); console.log(output); 

Output:

eeksforGeeks

Using array destructuring

The array destructuring allows us to mainly extract the values from the arrays and assign them to the variables. Then, we can join the characters into the new string.

Syntax:

let [variable1, variable2, ..., variableN] = array;

Example: In the below example, the [,...rest] uses the array destructuring to skip the first character of the input string, and then using the join method for joining the remaining characters into a new string.

JavaScript
let input: string = "GeeksforGeeks"; let [, ...rest] = input; let output: string = rest.join(''); console.log(output); 

Output:

eeksforGeeks

Using replace() method

The replace() method can be used to replace the matched character with an empty string, this can be done by giving the regular expression pattern as the argument to the method.

Syntax:

 str.replace(/^./, '');

Example: To demonstrate removing the first character in the input string and print the rest of the string character using the regular expression.

JavaScript
let input: string = "GeeksforGeeks"; let output: string = input.replace(/^./, ''); console.log(output); 

Output:

eeksforGeeks

Next Article
How to Declare an Array of Strings in TypeScript ?

G

gauravggeeksforgeeks
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • TypeScript

Similar Reads

  • JavaScript - Delete First Character of a String
    To delete the first character of a string in JavaScript, you can use several methods. Here are some of the most common ones Using slice()The slice() method is frequently used to remove the first character by returning a new string from index 1 to the end. [GFGTABS] JavaScript let s1 = "Geeksfor
    1 min read
  • Iterate Over Characters of a String in TypeScript
    Iterating over characters of a string involves going through them one by one using loops or specific methods. This is useful for tasks like changing or analyzing the content of a string efficiently. Example:Input: string = "Hello Geeks"; Output: H e l l o G e e k sBelow listed methods can be used to
    4 min read
  • How to Declare an Array of Strings in TypeScript ?
    Arrays are fundamental data structures in TypeScript, enabling developers to manage collections of elements efficiently. Below are the approaches to declare an Array of strings in TypeScript: Table of Content Square Brackets NotationArray ConstructorSquare Brackets NotationUsing square brackets nota
    1 min read
  • How to Iterate Over Characters of a String in TypeScript ?
    In Typescript, iterating over the characters of the string can be done using various approaches. We can use loops, split() method approach to iterate over the characters. Below are the possible approaches: Table of Content Using for LoopUsing forEach() methodUsing split() methodUsing for...of LoopUs
    2 min read
  • TypeScript String charAt() Method
    The String.prototype.charAt() method in TypeScript is used to return the character at the specified index of a string. The characters in the string are indexed from left to right, starting at 0. Syntax: string.charAt( index )Parameter: This method accepts a single parameter as mentioned above and de
    2 min read
  • TypeScript String charCodeAt() Method
    The String.charCodeAt() method in TypeScript returns the Unicode value of the character at a specified index in a string. It takes an integer index as a parameter and returns the corresponding Unicode value as a number. Syntaxstring.charCodeAt(index);Parameter: This method accepts a single parameter
    2 min read
  • TypeScript String.fromCharCode() Method
    The fromCharCode() is an inbuilt TypeScript String method. It mainly changes Unicode code points within the Basic Multilingual Plane (BMP) into strings. Although it provides a method for dealing with characters through typing on a keyboard it has restrictions when it comes to characters, outside the
    1 min read
  • How to remove the first character of string in PHP?
    Remove the very first character of a given string in PHP Examples: Input : GeeksforgeeksOutput : eeksforgeeksInput :, Hello geek!Output : Hello geek!Explanation: In PHP to remove characters from the beginning we can use ltrim but in that, we have to define what we want to remove from a string i.e. r
    3 min read
  • JavaScript - Delete Character from JS String
    In JavaScript, characters can be deleted from the beginning, end, or any specific position in a string. JavaScript provides several methods to perform these operations efficiently. Delete First CharacterTo remove the first character from a string, we can use methods like slice, substring, or regular
    2 min read
  • Reverse a String in TypeScript
    Reversing a string involves changing the order of its characters, so the last character becomes the first, and vice versa. In TypeScript, there are various methods to achieve this, depending on the developer's preference and the specific requirements of the task. Table of Content Using a LoopUsing A
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences