1. What is a JavaScript String?
- JavaScript strings are for storing and manipulating text.
-A JavaScript string is zero or more characters written inside quotes.
➡️Example:-
2. JavaScript Methods and Properties.
2.1. String length
To find the length of a string, use the built-in length property:
Example:-
2.2. slice() :-
-slice() extracts a part of a string and returns the extracted part in a new string.
-The method takes 2 parameters: the start position, and the end position (end not included).
-JavaScript counts positions from zero.
First position is 0.
Second position is 1.
2.3. substring():-
substring() is similar to slice().
The difference is that substring() cannot accept negative indexes.
Example:
2.4. substr();
substr() is similar to slice().
The difference is that the second parameter specifies the length of the extracted part.
Example:
2.5. Replacing String Content;-
The replace() method replaces a specified value with another value in a string:
Example:-
-This method does not change the string it is called on.
-It returns a new string.
-It replaces only the first match
-it is case sensitive.
2.6. toLowerCase():-
A string is converted to lower case with toLowerCase().
Example:-
2.7. toUpperCase();-
A string is converted to Upper case with toUpperCase().
Example:-
2.8. concat();-
concat() joins two or more strings.
Example;-
2.9, String trim():-
The trim() method removes whitespace from both sides of a string:
Example:-
3. String Padding:-
ECMAScript 2017 added two String methods: padStart and padEnd to support padding at the beginning and at the end of a string.
10.1. padStart():-
This Method will start giving padding from the start.
10.2. padEnd():-
This Method will start giving padding from the End.
Example:-
4. Extracting String Characters
There are 3 methods for extracting string characters:
4.1. charAt(position):-
The charAt() method returns the character at a specified index (position) in a string:
Example:-
4.2. charCodeAt(position):-
String charCodeAt()
The charCodeAt() method returns the unicode of the character at a specified index in a string:
The method returns a UTF-16 code (an integer between 0 and 65535).
Access ChatGPT-o1, DeepSeek-R1, Claude, Gemini, Llama, Grok, Midjourney, Ideogram, Flux Perplexity, Runway and Luma all in one place. Enjoy advanced AI models, image/video creation, and web search.
Here's how ↓
Meet GlobalGPT @GlbGPT - Your Ultimate All-In-One AI Platform.
Access ChatGPT 4.1, Midjourney v7, Grok 3, Claude 3.7, DeepSeek, Gemini, Llama 4, Flux, Ideogram, Perplexity, Runway, Luma, and more—all in one platform.
10 AI websites to finish a day’s work in just 1 hour
[Bookmark This 🔖]
1. Flot AI - Anywhere AI Assistant
Download for Free →
→ Flot is the all-in-one AI assistant that helps you write better, read faster, and remember information across any apps and websites.
→ Built-in the latest ChatGPT, Claude, Gemini, etc. Flot.ai
AiSOAP - #1 AI Medical Scribe with AI SOAP Notes
Try it free today! 🔗
Trust me, it’s a game-changer. 💥
→ AiSOAP records, transcribes, and generates customized SOAP notes, saving you 95% of your charting time. Sounds too good to be true? It’s not. 🙌Try.aisoap.com
• Transforms blurry ideas into actionable and data-backed analysis within 2 minutes.
• Turn weeks of inspiration researches into seconds, saving 99% of time
• Launch business with confidence, knowing market trends and optimized sourcing recommendation with suppliers thoroughly assessed and recommended.
• Gain business success faster!
2. MyScript Nebo / @myscript
→ Transforms text prompts into stunning, watermark-free images, allowing users to generate up to five artworks daily for free.
→ Offers extensive customization with different models, styles, aspect ratios, and starting photos.
→ Unlock daily trading opportunities with real-time event-driven insights & technical signals
→ Simplified, powerful tools for the intraday bottom and top signals—trade like a pro, effortlessly!
2. Spiking
→ The AI-powered stock tracking platform for smarter investments!
→ Leverage AI-driven insights to track market moves like the pros.
→ Get real-time data on what top investors are buying and selling.