how to check current typescript version?

Hi Friends 👋, Welcome To Infinitbility! ❤️ Check the global level of the typeScript version To check the current typescript version, open your terminal and run the tsc -v command it will show the current global version of TypeScript. Check TypeScript Version Getting error tsc not found You run the above command tsc -v but it shows the error 'tsc' not recognized as an internal or external command, it means typeScript does not install global level on your PC....

September 13, 2022 · 1 min · Infinitbility

how to check blank space in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check blank space in typeScript, use if...else statement with trim() method it will handle all falsy value like undefined, null, empty, blank and etc. Let’s see short example to use if...else with trim() method to check blank space in in typeScript. if(value.trim()){ } Today, I’m going to show you How do I check blank space in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 7, 2022 · 1 min · Infinitbility

how to check blank value in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check blank value in typeScript, use if...else statement it will handle all falsy value like undefined, null, empty, blank and etc. Let’s see short example to use if...else with value to check blank value in in typeScript. if(value){ } Today, I’m going to show you How do I check blank value in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 7, 2022 · 1 min · Infinitbility

how to check array is undefined in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check array is undefined in typeScript, use if...else statement it will handle all falsy value like undefined, null, empty and etc. Let’s see short example to use if...else with array to check array is undefined in typeScript. if(array){ } Today, I’m going to show you How do I check array is undefined in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 6, 2022 · 1 min · Infinitbility

how to check a variable is undefined in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check a variable is undefined in typeScript, use if...else statement it will handle all falsy value like undefined, null, empty and etc. Let’s see short example to use if...else with variableName to check a variable is undefined in typeScript. if(variableName){ } Today, I’m going to show you How do I check a variable is undefined in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 5, 2022 · 1 min · Infinitbility

how to check array is null or not in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check array is null or not in typeScript, use if...else statement it will handle all falsy value like undefined, null, empty and etc. Let’s see short example to use if...else with array to check a array is null in typeScript. if(array && array.length){ } Today, I’m going to show you How do I check array is null or not in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 4, 2022 · 1 min · Infinitbility

how to check array or not in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To check array or not in typeScript, use Array.isArray() method it will true or false based on value we have provided, even it’s detect between object or instance of array. Let’s see short example to use if...else with Array.isArray() to check array or not in typeScript. if(Array.isArray(array)){ } Today, I’m going to show you How do I check array or not in typeScript, as above mentioned, I’m going to use the above-mentioned if....

September 3, 2022 · 1 min · Infinitbility

how to get last word of string in typeScript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get last word of string in typeScript, use split(" ") method with strArr.length - 1 index value it will return last word from string. You have to only pass " " in split() method. Let’s see short example to use split(" ") with with strArr.length - 1 index to get last word from string. let strArr: Array<string> = string.split(" "); strArr[strArr.length - 1]; Today, I’m going to show you How do I get last word of string in typeScript, as above mentioned, I’m going to use the above-mentioned split() method....

August 21, 2022 · 1 min · Infinitbility

how to get first word of string in typeScript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get first word of string in typeScript, use split(" ") method with 0 index value it will return first word from string. You have to only pass " " in split() method. Let’s see short example to use split(" ") with with 0 index to get first word from string. string.split(" ")[0]; Today, I’m going to show you How do I get first word of string in typeScript, as above mentioned, I’m going to use the above-mentioned split() method....

August 19, 2022 · 1 min · Infinitbility

how to get each character of string in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To each character of string in typescript, use for...of loop, it will return each character one by one. You have to just use for...of loop on your string string. Let’s see short example to use for loop on string to get each char. for (let char of string) { console.log(char) } Today, I’m going to show you How do I get each character of string in typescript, as above mentioned, I’m going to use the for....

August 18, 2022 · 1 min · Infinitbility

how to get last two character of string in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get last two character of string in typescript, use substring() method to extracts last two character from string. You have to only pass starting and ending postion of string so for last two character pass text.length - 2 as parameter it will return last two character of string. Let’s see short example to use substring() to get last two character from string....

August 17, 2022 · 1 min · Infinitbility

how to get last character of string in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get last character of string in typescript, use substring() method to extracts last character from string. You have to only pass starting and ending postion of string so for last character pass text.length - 1 as parameter it will return last character of string. Let’s see short example to use substring() to get last character from string. text.substring(text.length - 1); Today, I’m going to show you How do I get last character of string in typescript, as above mentioned, I’m going to use the above-mentioned substring() method....

August 16, 2022 · 2 min · Infinitbility

how to get first two character of string in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get first two character of string in typescript, use substring() method to extracts first two character from string. You have to only pass starting and ending postion of string so for first two character pass 0, 2 as parameter it will return first two character of string. Let’s see short example to use substring() to get first two character from string. text.substring(0, 2); Today, I’m going to show you How do I get first two character of string in typescript, as above mentioned, I’m going to use the above-mentioned substring() method....

August 15, 2022 · 1 min · Infinitbility

how to get first character of string in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To get first character of string in typescript, use substring() method to extracts first character from string. You have to only pass starting and ending postion of string so for first character pass 0, 1 as parameter it will return first character of string. Let’s see short example to use substring() to get first character from string. text.substring(0, 1); Today, I’m going to show you How do I get first character of string in typescript, as above mentioned, I’m going to use the above-mentioned substring() method....

August 13, 2022 · 2 min · Infinitbility

how to handle apostrophe in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To handle apostrophe ( single quote, or double quote ) in typescript, use the ( \ ) Escape characters or ( ` ) Template literals it will handle both types quotes single and double. Let’s see how Escape characters and Template literals will solve the issue. let brokenString: string = 'I'm a broken string'; console.log(brokenString); // Output // unknown: Unexpected token (1:24) brokenString: string = 'I\'m a broken string'; console....

August 9, 2022 · 2 min · Infinitbility

How to remove item from object in typescript?

Hi Friends 👋, Welcome To Infinitbility! ❤️ To remove the item from an object in typescript, use the delete keyword it will remove the key-value pair from an object only you have to mention the delete keyword with the key. typescript object is one of the most used concepts and we will use it every day almost but sometimes we need to delete some key-value pair. Today, we will see how we can remove items from the typescript object using a key....

August 9, 2022 · 1 min · Infinitbility

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