Javascript

Javascript: String Replace Space with Dash

A general requirement while working with javascript is to process strings and replace particular characters with some other. One such condition is to replace spaces with the dash in javascript strings. Table of Contents:- Javascript string replace spaces with dash using replace() Javascript string replace spaces with dash using split() and join() Javascript string replace […]

Javascript: String Replace Space with Dash Read More »

Javascript: Check if string contains special characters

This article will discuss checking if a string contains special characters in a javascript string using different methods and example illustrations. Table of Contents: Check if a string contains special characters using test() Check if a string contains special characters using indexOf() Check if a string contains special characters using test() Javascript’s test(string) method searches for

Javascript: Check if string contains special characters Read More »

Javascript: Replace with RegEx Example

This article demonstrates how to use the replace() function in javascript with regular expressions using different examples of replacing characters from a string. Table of Contents: Introduction and Syntax of replace() function Example 1: Replace special characters from a string Example 2: Replace spaces from a string Example 3: Replace anything but digits from a string Introduction

Javascript: Replace with RegEx Example Read More »

Javascript: Replace multiple spaces with a single space

A lot of standard requirements are there in javascript related to the processing of strings. One such generic requirement is to replace multiple spaces with a single space in a javascript string. This article will discuss and demonstrate how to remove duplicate spaces using various example illustrations. Table of Contents:- Replace multiple spaces with a

Javascript: Replace multiple spaces with a single space Read More »

Javascript: Capitalize first letter of each word in a string

This article will discuss a general requirement to make the first letter of each word capital in a javascript string. Table of Contents:- Capitalize first letter of each word in string using Regular Expressions Capitalize first letter of each word in string using split() and for loop Capitalize first letter of each word in string

Javascript: Capitalize first letter of each word in a string Read More »

Javascript: How to make first letter of a string uppercase

Strings are JavaScript’s data type used to represent the textual data and are most commonly used. Many people encounter a general requirement to Capitalize the first letter of a String. This article will discuss different ways to make the first letter uppercase using examples. Javascript’s toUpperCase() will return the calling string converted to uppercase. If

Javascript: How to make first letter of a string uppercase Read More »

Delete all occurrences of a character in javascript string

This article will discuss removing all the occurrences of a character from a javascript string using simple methods and example illustrations. Table of Contents:- Delete all occurrences of a character in javascript string using replace() and RegEx Delete all occurrences of a character in javascript string using replaceAll() Delete all occurrences of a character in

Delete all occurrences of a character in javascript string Read More »

Delete part of string by index position in javascript

This article will discuss removing part of the string either from the start of the string or from the end based on an index position. There will be illustrations using different examples. Table of Contents:- Javascript string remove from start till the index Javascript string remove from index to end Javascript string remove from start

Delete part of string by index position in javascript Read More »

Difference between slice() and substring() in javascript

The two popular methods of javascript strings slice() and substring() are very similar, but there are a few differences. This article discusses the differences between the slice() and substring() methods using various scenarios and example illustrations. Let’s start looking into the syntax of both: syntax of slice():- Here, The indexes of the slice() method are zero-based. The startIndex specifies from

Difference between slice() and substring() in javascript Read More »

Scroll to Top