how to remove duplicates from array in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove duplicates from array in typescript, use the new Set() method with it will create new array without dublicate elements. The Set object lets you store unique values of any type, whether primitive values or object references. To use new set in array you have to follow below syntax. [...new Set(arr)] Today, I’m going to show you How do I remove duplicates from array in typescript, as above mentioned, I’m going to use the above-mentioned new Set() method to get only unique elements of array....

August 3, 2022 · 1 min · Infinitbility

how to empty an array in javascript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To empty an array in javascript, use the splice() method with array length it will delete all elements of the array without compromise with reference, and also it is one of the fastest ways to empty an array. The splice() method takes the index (from which the splicing should start ) and the number of items to be removed as parameters and splices the elements....

August 2, 2022 · 1 min · Infinitbility

how to empty an array in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To empty an array in react js, set [] empty array in a state it will remove the existing array of elements and store a new empty array in a state. setArr([]); Today, I’m going to show you How do I empty an array in react js, as above mentioned, I’m going to use the above-mentioned set [] empty array syntax method to empty an array....

August 2, 2022 · 1 min · Infinitbility

how to empty an array in react native?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To empty an array in react native, set [] empty array in a state it will remove the existing array of elements and store a new empty array in a state. setArr([]); Today, I’m going to show you How do I empty an array in react native, as above mentioned, I’m going to use the above-mentioned set [] empty array syntax method to empty an array....

August 2, 2022 · 1 min · Infinitbility

how to empty an array in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To empty an array in typescript, use the splice() method with array length it will delete all elements of the array without compromise with reference, and also it is one of the fastest ways to empty an array. The splice() method takes the index (from which the splicing should start ) and the number of items to be removed as parameters and splices the elements....

August 2, 2022 · 1 min · Infinitbility

how to pass parameter to a promise function in javascript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To pass parameters to a promise function in javascript, create a parameter function and use promise in a function like the below example. var getNameById = function (id) { return new Promise(function (resolve, reject) { // ... }); }; getNameById(3).then(function (res) { console.log(res); }); // output: "Stuff worked" Today, I’m going to show you How do I pass parameters to a promise function in javascript, as above mentioned, I’m going to use the above-mentioned syntax to create and use a promise function with a parameter....

August 1, 2022 · 2 min · Infinitbility

how to pass parameter to a promise function in react js?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To pass parameters to a promise function in react js, create a parameter function and use promise in a function like the below example. var getNameById = function (id) { return new Promise(function (resolve, reject) { // ... }); }; getNameById(3).then(function (res) { console.log(res); }); // output: "Stuff worked" Today, I’m going to show you How do I pass parameters to a promise function in react js, as above mentioned, I’m going to use the above-mentioned syntax to create and use a promise function with a parameter....

August 1, 2022 · 2 min · Infinitbility

how to pass parameter to a promise function in react native?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To pass parameters to a promise function in react native, create a parameter function and use promise in a function like the below example. var getNameById = function (id) { return new Promise(function (resolve, reject) { // ... }); }; getNameById(3).then(function (res) { console.log(res); }); // output: "Stuff worked" Today, I’m going to show you How do I pass parameters to a promise function in react native, as above mentioned, I’m going to use the above-mentioned syntax to create and use a promise function with a parameter....

August 1, 2022 · 2 min · Infinitbility

how to pass parameter to a promise function in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To pass parameters to a promise function in typescript, create a parameter function and use promise in a function like the below example. const getNameById = (id: number): Promise<string> => { return new Promise(function (resolve, reject) { // ... }) } Today, I’m going to show you How do I pass parameters to a promise function in typescript, as above mentioned, I’m going to use the above-mentioned syntax to create and use a promise function with a parameter....

August 1, 2022 · 1 min · Infinitbility

how to check null value in json object in javascript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check the null value in a JSON object in javascript, Just use the if statement or ternary operator before using the JSON object value. it will handle all falsy values with null. JavaScript if statement or ternary opertor will handle (""), null, undefined, false and the numbers 0 and NaN. Let’s take a short example check the null value in JSON object in javascript....

July 31, 2022 · 2 min · Infinitbility

how to set value in json object in javascript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To set value in JSON object in javascript, we have multiple ways Set the value at the time of creating JSON object Set value using the key in JSON object Set value using dynamic key in JSON object Let’s take a short example of all the above methods. // Set value at the time of creating JSON object let obj = { id: 1 } // Set value using key in json object obj....

July 30, 2022 · 2 min · Infinitbility

how to check if a string contains only whitespace in typescript?

Check if a string contains only whitespace in typescript To check if a string contains only whitespace in typescript, you can use the trim() method with the if...else statement it will go in else if the string contains blank spaces. // ✅ Check if a string contains only whitespace Using `trim()` method (" ".trim()) ? "String contain character" : "String contain only spaces"; // 👉️ 'String contain only spaces' Today, I’m going to show you How do I check if a string contains only whitespace in typescript, as above mentioned here, I’m going to use the trim() method with the if....

July 28, 2022 · 2 min · Infinitbility

how to get length of numbers in typescript?

Get the length of numbers in typescript To get the length of numbers in typescript, you can use the toString() method with the length property it will return the length of numbers. // ✅ Get the length of numbers in typescript let num: number = 493054; num.toString().length; // 👉️ 6 Today, I’m going to show you How do I get the length of numbers in typescript, as above mentioned here, I’m going to use thetoString() method with the length property to get the length of numbers;...

July 28, 2022 · 1 min · Infinitbility

how to get length of object in typescript?

Get the length of the object in typescript To get the length of the object in typescript, you can use the Object.keys() method with the length property it will return the length of the object. // ✅ Get the length of the object in typescript let num: number = 493054; Object.keys({id: 1, name: "infinitbility.com"}).length; // 👉️ 2 Today, I’m going to show you How do I get the length of the object in typescript, as above mentioned here, I’m going to use theObject....

July 28, 2022 · 1 min · Infinitbility

how to add number to string in typescript?

Add a number to a string in typescript To add the number to a string in typescript, you can use the + addition operator or ${} template literal to add a number in a string both can add the number to a string. // ✅ Using `+` addition operator 5 + "0" 👉️ "50" // ✅ Using `${}` template literal `${5}0` 👉️ "50" Today, I’m going to show you How do I add a number to a string in typescript, as above mentioned here, I’m going to use the + addition operator or ${} template literal to add the number to a string....

July 27, 2022 · 2 min · Infinitbility

how to call script type module function in javascript?

To call script type module function in javascript, assign function in window object, then you can call a function from anywhere. let’s take an example of creating and assigning a function in a window object. <script type="module"> window.showAlert = function showAlert() { alert("Button Clicked"); }; </script> Today, I’m going to show you How do I call script type module function in javascript, as above mentioned here, I’m going to use the window object to make the function accessible....

July 26, 2022 · 1 min · Infinitbility

how to upload base64 image to ipfs?

To upload a base64 image to ipfs, convert the base64 image to a blob using the fetch() method and then you can able to upload the base64 image to IPFS. Take the sort of example of uploading a base64 image to IPFS. const response = await fetch(base64Image); const blob = await response.blob(); const file = new File([blob], "file.png", { type: "image/png" }); const imghash = await ipfs.add(file); Today, I’m going to show you How do I upload base64 images to ipfs, as above mentioned here, I’m going to use the fetch() method to make files uploadable and ipfs-http-client package to upload file in IPFS....

July 26, 2022 · 2 min · Infinitbility

how to get browser name in react js?

To get the browser name in react js, install the platform package and call platform.name it will return the browser name. Take the example of using the platform package to get the browser name in react js. import platform from 'platform'; platform.name; // 'IE' ( your users browser name ) Today, I’m going to show you How do I get the browser name in react js, as above mentioned here, I’m going to use the platform package to check the browser name....

July 25, 2022 · 1 min · Infinitbility

how to get browser version in react js?

To get the browser version in react js, install the platform package and call platform.version it will return the browser version. Take the example of using the platform package to get the browser version in react js. import platform from 'platform'; platform.version; // '10.0' Today, I’m going to show you How do I get the browser version in react js, as above mentioned here, I’m going to use the platform package to check the browser version....

July 25, 2022 · 1 min · Infinitbility

how to export constants in typescript?

Export constants in typescript To export constants in typescript, use the export keyword it will export your constants, variables, or functions. To use export constants, variables, or functions in typescript, use the import keyword. using the import keyword you can easily use exported module. Today, I’m going to show you How do i export constants in typescript, as mentioned above, I’m going to use the use export statement to export constants and use them in another file....

July 24, 2022 · 1 min · Infinitbility