Found 8894 Articles for Front End Technology

How to compare two strings in the current locale with JavaScript?

Shubham Vora
Updated on 17-Aug-2022 08:16:00

475 Views

In this tutorial, we will learn to compare two strings in a current locale with JavaScript. The meaning of the locale is local place or region. Here, we need to compare two strings based on the language of the particular locale. Normally, when users compare the strings using equality or strict equality operators, it doesn’t compare strings based on the current locale. So, we will learn to compare the two strings based on the language of the particular locale. Compare two strings using the localeCompare() Method The String localeCompare() method compares the string with the reference string according to the ... Read More

How to return a new string with a specified number of copies of an existing string with JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 06:40:02

138 Views

In this tutorial, we will explore the methods by which we can repeat a string a certain number of times, again and again, to make a new string in JavaScript. There are many scenarios where we may want to make a new string which is just another string repeated ‘x’ number of times and we will see how to achieve that easily using inbuilt methods provided by JavaScript. We want to create a new string which is just another string copied some number of times. Although we can accomplish this task manually by using a for loop or a while ... Read More

Find the non-digit character with JavaScript Regular Expression

Sravani Alamanda
Updated on 08-Dec-2022 10:26:56

2K+ Views

In this tutorial, we will learn to find the non-digit character with JavaScript regular expression. ASCII code 'A' is 65 and 'a' is 97 etc. Now, we will check how to find a nondigit element (\D) in a given text using RegExp. RegExp is an object that specifies the pattern used to do search and replace operations on string or for input validation. RegExp was introduced in ES1 and it is fully supported by all browsers. Syntax Syntax for the non-digit element is, new RegExp("\D") or simply /\D/ /\D/, is introduced in ES1. It is fully supported by ... Read More

Find non-word character in a string with JavaScript RegExp

Sravani Alamanda
Updated on 08-Dec-2022 10:06:31

1K+ Views

In this tutorial, we learn how to find non-word characters in a string using JavaScript Regular Expression. Actually, word characters include A-Z, a-z, 0-9 and _. Coming to the non-word characters except word characters like !, @, #, $, %, ^, &, *, (, ), {, } etc. Non-word characters, we denote as \W. We all know about RegExp (Regular Expression) in JavaScript. RegExp is an object that specifies the pattern used to do a search and replace operations on a string or for input validation. RegExp was introduced in ES1 and it is fully supported by all browsers. ASCII ... Read More

Find digits not between the brackets using JavaScript Regular Expressions?

Sravani Alamanda
Updated on 08-Dec-2022 09:22:47

81 Views

In JavaScript, the regular expression [^0-9] is used to find the characters inside the bracket but not a digit. Except digit mentioned in the bracket, it will return the remaining characters from the text as an array. We all know about RegExp (Regular Expression) in JavaScript. RegExp is an object that specifies the pattern used to do a search and replace operations on the string or for input validation. RegExp was introduced in ES1 and it is fully supported by all browsers. Syntax Syntax for non-digit or /[^0-9]/ character is- new RegExp("[^0-9]") or simply /[^0-9]/ Here /[^0-9]/ , ... Read More

How to find character between brackets in JavaScript RegExp?

Abhishek
Updated on 31-Oct-2022 07:32:04

1K+ Views

In this tutorial, we will learn how we can find a character between the brackets in JavaScript RegExp with examples. Syntax Following is the syntax that you have to follow for finding the character between the brackets of JavaScript RegExp − [……] In the above syntax, you can put the character or the combination of characters that you are searching in place of dots while the square brackets are the basic syntax to indicate the use of JavaScript RegExp. Below is the list of different syntaxes that you can use to check for the presence of different characters in ... Read More

How to find a character, not between the brackets in JavaScript RegExp?

Abhishek
Updated on 31-Oct-2022 07:30:26

993 Views

RegExp or RegEx in JavaScript is the short form of Regular Expressions. Regular Expressions are used to check validity of a particular combination of characters, digits, or any other symbol entered by the user. Regular expressions are mainly used for checking valid emails, and passwords that authenticate the correct user to log in. In this tutorial, we will learn how we can find a character that is not present between the brackets of JavaScript RegExp. Syntax Following is the syntax that is used to find the character, not between the brackets of JavaScript RegExp − [^……] In above syntax, ... Read More

Find word character in a string with JavaScript RegExp?

Sravani Alamanda
Updated on 08-Dec-2022 09:28:45

899 Views

In this tutorial, we will see how to find a word character from the text. Word character denote as \w. Word character is a character like a-z, A-Z and 0-9 and also includes underscore(_). We all know about RegExp (Regular Expression) in js. RegExp is an object and specifies the pattern used to do search and replace operations on string or for input validation. RegExp was introduced in ES1 and it is fully supported by all the browsers. ASCII code for A-Z is 65- 90, a-z is 97-122, 0-9 is 48-57 and for underscore is 95. Syntax Syntax for word ... Read More

What are the different types of DOM available to access and modify content in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:54:22

875 Views

In this tutorial, we will learn what are the different types of DOM available to access and modify content in JavaScript. The Document Object Model (DOM) is a data representation of the objects that form the structure and content of a web document. It is an interface for scripting web pages. Programs can alter the document’s structure, style, and content by utilizing the DOM. The DOM represents each element as a node, and the programming languages like JavaScript can easily interact with the nodes to modify the page. There are different types of DOM available to access and modify content ... Read More

What are the three types of errors I can expect in my JavaScript script?

Shubham Vora
Updated on 31-Oct-2022 11:21:36

332 Views

In this tutorial, let us discuss the three types of errors we can expect in our JavaScript code. Errors are statements that block the execution of the program. During the compilation of the program, three types of errors can occur. These are syntax errors, run time errors, and logical errors. Syntax Errors Syntax errors are usual errors. Incorrect syntax causes parsing issues during the code interpretation. For example, add a semicolon instead of a colon in an object declaration. Syntax errors affect only the respective code thread. The remaining code works as it is. A grammatical mistake is the ultimate ... Read More

Advertisements