how to check webpack version in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check webpack version in react js, Open the terminal ( CMD ) and navigate to your project. run the npm list webpack or yarn list webpack command it will list down all your packages with their webpack version. Today, I’m going to show you How do I check webpack version in react js, as above mentioned here, I’m going to use the npm list or yarn list commands....

July 15, 2022 · 1 min · Infinitbility

how to remove double quotes from string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove double quotes from a string in react js, 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 14, 2022 · 2 min · Infinitbility

how to remove word from a string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove word from string in react js, just use the replace() method and pass the first parameter word which you want to remove, the second parameter empty string so the method replaces your word with an empty string and returns the new string. 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 14, 2022 · 2 min · Infinitbility

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 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 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

react js convert string to number

Hi Friends 👋, Welcome To Infinitbility! ❤️ To convert a string to a number in react 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 react js, as above mentioned here, I’m going to use the plus operator and string interpolation....

July 3, 2022 · 2 min · Infinitbility

how to get length of array in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get the length of the array in react js, use the array length property it will return your array elements count. The length property of an object which is an instance of type Array sets or returns the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array....

July 2, 2022 · 2 min · Infinitbility

how to get length of object in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get length of object in react js, convert the object to array using the Object.keys() method and use the array length property it will return of your number of object. The length property of an object which is an instance of type Array sets or returns the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array....

July 2, 2022 · 2 min · Infinitbility

how to find length of number in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get the length of the number in react js, convert the number to string using the toString() method and use the String length property it will return of your number 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 number, convert it into string and use string length to get the length of your number....

July 1, 2022 · 2 min · Infinitbility

how to find length of string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get the length of the string in react 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 1, 2022 · 2 min · Infinitbility

how to convert json object to string in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To convert JSON object to string in react js, use the JSON.stringify() method it will return the object as a string, and then you can do as you want like sending through API or storing in local storage. In the following example, we will take the JSON object example and convert it into a string. let obj = {id: 1, name: "infinitbility"}; console.log(JSON.stringify(obj)) // '{"id":1,"name":"infinitbility"}' Today, I’m going to show you How do i convert a JSON object to a string in react js, as above mentioned here, I’m going to use the JSON....

June 30, 2022 · 2 min · Infinitbility