how to remove special characters from string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove special characters from string in react js, just use replace() method with /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/g regex then it will return new string without special characters. The replace() method returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function called for each match....

July 12, 2022 · 2 min · Infinitbility

how to remove first character from string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove first character from string in react js, just use substring(1) method it will return new string based on provided index so if you pass 1 as parameter it returns the string without 0 index char. The substring() method returns the part of the string between the start and end indexes, or to the end of the string. Let’s take an example to remove first alphabet using the substring() method....

July 11, 2022 · 2 min · Infinitbility

how to remove last character from string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove last character from string in react js, just use substring(0, lastindex - 1) method it will return new string based on the provided index so if you pass 0, lastindex - 1 as parameter it returns the string without last index char. The substring() method returns the part of the string between the start and end indexes, or to the end of the string....

July 11, 2022 · 2 min · Infinitbility

how to remove html tags from string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove html tags from string in react js, just use the /(<([^>]+)>)/ig regex with replace() method it will remove tags with their attribute and return new string. Let’s do some example Take sample html string, remove their tags using /(<([^>]+)>)/ig regex with replace() method. const htmlStr = "<h1>Infinitbility, </h1><p>We have the ability to build infinite way for us.</p>"; const newStr = htmlStr.replace(/(<([^>]+)>)/ig, ''); // 👇️ 'Infinitbility, We have the ability to build infinite way for us....

July 10, 2022 · 2 min · Infinitbility

how to sort array of string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To sort array of string in react js, use the sort() method with localeCompare() method it will sort array and return new array based on your condition. The sort() method sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending. The localeCompare() method returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order....

July 10, 2022 · 2 min · Infinitbility

how to center text in react native?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To center text in react native, just use the textAlign css property it will center text horizontaly and for vertical center flex: 1, justifyContent: "center", on upper element. Today, I’m going to show you How do I center text in react native, as above mentioned here, I’m going to use the textAlign and justifyContent css property to make text center. Let’s start today’s tutorial how do you center text in react native?...

July 9, 2022 · 2 min · Infinitbility

how to check empty object in node js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check the empty object in node js, just use the Object.keys() method it will create an array of object keys after then you can check the length and if it’s equal to 0 means the object is empty. Like the following example, let’s take the below array of objects example here we will find an index of id 3 and delete it from the array....

July 9, 2022 · 2 min · Infinitbility

how to check empty object in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check the empty object in react js, just use the Object.keys() method it will create an array of object keys after then you can check the length and if it’s equal to 0 means the object is empty. Like the following example, let’s take the below array of objects example here we will find an index of id 3 and delete it from the array....

July 9, 2022 · 2 min · Infinitbility

how to add string to array in node js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To add string to array in node js, just use the push() method it will add your data into an array as the last element. Like the following example, we can add string to array using the push() method. let arr = ["infinitbility","aguidehub"]; arr.push("sortoutcode"); console.log(arr); // ['infinitbility', 'aguidehub', 'sortoutcode'] Today, I’m going to show you How do i add string to array in node js, as above mentioned here, I’m going to use the push() method for adding new elements into the array....

July 8, 2022 · 2 min · Infinitbility

how to kill process using port in windows?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To kill process using port in windows, open your cmd as administrator and do run netstat -ano | findstr :<PORT> (replace <PORT> with your port number ) copy PID number which you want kill in the list run taskkill /PID <PID> /F (replace <PID> with your pid number ) That’s it. Sometime’s we want to run some application like node, react, golang, graphQL and etc but windows show this port already in used in my case i want to start start react application on 3000 port but i’m not able to start because something working on 3000 port....

July 8, 2022 · 2 min · Infinitbility

how to check empty string in node js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check an empty string in node js, use the if..else statement just pass and put your string variable in an if condition if it’s empty it will go to the else statement. In the following example, we will take the sample empty string and use the if..else statement. let str = ""; if(str){ console.log("str is not empty"); } else { console.log("str is empty"); } // str is empty Today, I’m going to show you How do i check an empty string in node js, as mentioned above, I’m going to use the use if....

July 7, 2022 · 2 min · Infinitbility

how to get length of string in node js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get length of string in node js, use the String length property it will return your string char count. The length property of a String object contains the length of the string, in UTF-16 code units. length is a read-only data property of string instances. In the following example, we will take the sample string and use string length to get a count of the string....

July 7, 2022 · 2 min · Infinitbility

node js convert string to number

Hi Friends 👋, Welcome To Infinitbility! ❤️ To convert a string to a number in node js, you can use the + plus operator it’s the fastest way to convert a string to a number. In the following example, we will take the sample string variable, and convert it into an integer using the plus operator. let text = "24325"; // using plus operator let num = +text; console.log(num) // 24325 Today, I’m going to show you How do i convert string to number in node js, as above mentioned here, I’m going to use the plus operator and string interpolation....

July 7, 2022 · 2 min · Infinitbility

how to remove double quotes from string in react native?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove double quotes from a string in react native, just use the replaceAll('"', '') method it will replace double quotes with an empty string and return a new string without double quotes. Like the following example, let’s take the below sample string example here we will remove all double quotes available in the string. const str = 'Hi" Friend"s, Welcome "to" infinitbility'; // 👇️ 'Hi Friends, Welcome to infinitbility' str....

July 6, 2022 · 2 min · Infinitbility

how to replace string in node js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To replace string in node js, use the replace() and use replace() with /PUT_HERE_REPLACEABLE_STRING/g regex method. the replace() method replace your first occurrence ( match ) from your string the replace() method with regex will replace all occurrences from your string Just you have to pass two parameters, in the first parameter you have to pass what you want to replace and in the second parameter you have to pass what you want to put in the place of replace string....

July 6, 2022 · 2 min · Infinitbility

how to check if string contains substring in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check the string that contains a substring in react js, use the includes() method, it will return true or false based on string contains a substring or not. In the following example, we will take the samples string and substring, and check the string contains a substring using the includes() method. let string = "hi friends welcome to infinitbility"; let substring = "infinitbility"; string....

July 5, 2022 · 2 min · Infinitbility

how to generate random number in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To generate a random number in react js, use the Math.random() method it will generate a random number. In the following example, we set the min and max number with the Math.random() method so it will generate random numbers in the range of min and max number. function getRandomNumber() { let min = 1000; let max = 9999; return Math.round(Math.random() * (max - min) + min); } getRandomNumber(); // return 4 char random number Today, I’m going to show you How do i generate random numbers in react js, as mentioned above here, I’m going to use the Math....

July 5, 2022 · 2 min · Infinitbility

how to add two numbers in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To add two numbers in react js, use the + addition operator it will add if your value datatype is a number else if your value datatype is string first convert it using parseInt() and then perform addition operation. In the following example, we will take the sample numbers, and strings and perform add operation using the + addition operator. Adding Two numbers example let num1 = 30; let num2 = 34; num1 + num2; // 64 Adding Two string numbers example let num1 = "30"; let num2 = "34"; parseInt(num1) + parseInt(num2); // 64 Today, I’m going to show you How do i add two numbers in react js, as mentioned above here, I’m going to use the + addition operator....

July 4, 2022 · 2 min · Infinitbility

how to replace string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To replace string in react js, use the replace() or replaceAll() method. the replace() method replace your first occurrence ( match ) from your string the replaceAll() method will replace all occurrences from your string Just you have to pass two parameters, in the first parameter you have to pass what you want to replace and in the second parameter you have to pass what you want to put in the place of replace string....

July 4, 2022 · 2 min · Infinitbility

how to concat string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To concat string in react js, you can use + plus operator or ES6 string interpolation both will help for your string concatenation. In the following example, we will take the sample string variable, and do concatenation using both ways ( plus operator and string interpolation ). let text = "infinitbility.com"; // using plus operator let str1 = "One of the best site is " + text; console....

July 3, 2022 · 2 min · Infinitbility