How to convert date to number in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to number in typescript?, here we will use date built-in method Date.parse() method to convert date to number format. So, let’s see what is Date.parse() method? The Date.parse() method parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or NaN if the string is unrecognized or, in some cases, contains illegal date values (e....

April 27, 2022 · 1 min · Infinitbility

How to convert date to epoch time in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to epoch time in typescript, here we will use built-in method Date.parse() method to convert date to epoch time. First of all, let understand what is a epoch time? The Unix epoch or Unix time is the number of seconds elapsed since January 1, 1970. The getTime() method is used to return the millisecond representation of the Date object....

April 26, 2022 · 1 min · Infinitbility

How to convert date to string format in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to date string format in typescript, here we will use built-in method .toString() to convert date to string date. First, we will create sample new date() object variable, after then, we will use .toString() method to convert it on string date format. let’s dive in code… let date = new Date(); console.log(date); // 2022-04-25T08:21:19....

April 25, 2022 · 1 min · Infinitbility

How to convert date to utc format in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert date to utc format in typescript, here we will use built-in method .toUTCString() to convert date to utc date. First, we will create sample new date() object variable, after then, we will use .toUTCString() method to convert it on utc date format. let’s dive in code… let date = new Date(); console.log(date); // 2022-04-24T11:26:53.690Z let utcDate: string = date....

April 24, 2022 · 1 min · Infinitbility

How to convert string to char array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn How to convert string to char array in typescript, here we will use built-in method .split() to convert string to array. Well, we have sample an string which we have to seprate and we have to pick those data and use as array. To do this things, we have built-in method .split() which we have to provide empty string seprator for to seprate every string char element....

April 23, 2022 · 1 min · Infinitbility

How to convert string to title case in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn how to convert string in any case like camel case, paskal case to title case in typescript, here we will create toTitleCase() custom method to convert string any case to title case. Well, let’s create a function which return the provided string with the first letter of each word capitalized and Make sure the rest of the word is in lower case....

April 22, 2022 · 1 min · Infinitbility

How to convert comma separated string to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to learn how to convert comma (,) separated string to array in typescript, here we will use built-in method .split() to convert string to array. Well, we have an string which have comma ( , ) seprate data and we have to pick those data and use as array. To do this things, we have built-in method .split() which we have to provide seprator for now it’s comma and it will return an array....

April 20, 2022 · 1 min · Infinitbility

How to convert a string to uppercase in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert a string to uppercase in typescript, here we will use the javascript toUpperCase() method to convert it an uppercase. So first, we will create some examples variables, then we use the toUpperCase() method on those variables, and then we will check our console it’s working or not. Let’s start codeing… let firstStr: string = 'Hello World'; let secondStr: string = 'Infinitbility'; let thirdStr: string = 'IfergUokgIgokr04'; // lets convert it firstStr = firstStr....

April 17, 2022 · 1 min · Infinitbility

How to convert a string to lowercase in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert string to lowercase in typescript, here we will use the javascript toLowerCase() method to convert to lowercase. So first, we will create some examples variables, then we use the toLowerCase() method on those variables, and then we will check our console it’s working or not. Let’s start coding… let firstStr: string = 'Hello World'; let secondStr: string = 'Infinitbility'; let thirdStr: string = 'IfergUokgIgokr04'; // lets convert it firstStr = firstStr....

April 16, 2022 · 1 min · Infinitbility

How to convert any to string in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! This tutorial will help you to convert any type of data to a string in typescript, here we will use the built-in method .toString() method to convert data any type to a string. we will first create any type variable with sample array data and then we will check their data type. after that we will use the .toString() method to convert it into a string....

April 14, 2022 · 1 min · Infinitbility

How to convert object to json string in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert the object to JSON string in typescript, here we will use the built-in method JSON.stringify() to convert data object to JSON string. When you want to pass data to API or anywhere then you should stringify your JSON. Here, we will create a sample object and then we use JSON.stringify() to convert the object to a string....

April 14, 2022 · 1 min · Infinitbility

How to convert string to json in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert string to object in typescript, here we will use the built-in method JSON.parse() to convert data string to JSON. When you get a string from any API or anywhere and it looks like JSON key-value pair for example '{"id":1,"name":"infinitbility","domain":"infinitbility.com","age":2,"isActive":1}' and you won’t use it then first you to parse it. let’s start code....

April 14, 2022 · 1 min · Infinitbility

How to convert string to boolean in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, we are going to see how we can convert string to boolean in typescript, here we are going to use the ternary operator to convert string to boolean. To convert a string to a boolean, we have to check whether 'true' is present in the string or not, and if present we have to assign a new true value or false. In the following code, we are taken of both cases if the string true or if string false....

April 13, 2022 · 1 min · Infinitbility

How to convert a string to camel case in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how can we convert normal string text to camel case in typescript, If you are using lodash then you have to just use their available camel case convert method. _.camelCase('Foo Bar'); // → 'fooBar' _.camelCase('--foo-bar--'); // → 'fooBar' _.camelCase('__FOO_BAR__'); // → 'fooBar but in this article, we are going to create a custom function that converts text to camelCase text....

April 11, 2022 · 2 min · Infinitbility

How to convert object keys to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert object keys to array in typescript, here we use some javascript Objects method like Object.keys() method. Sometime’s we need to create array from object keys and that’s why we simple method Object.keys() interface User { id: number; name: string; domain?: string; age?: number; isActive?: boolean; } let user: User = { id: 1, name: "infinitbility", domain: "infinitbility....

April 9, 2022 · 1 min · Infinitbility

How to convert object values to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert object values to array in typescript, here we use some javascript Objects method like Object.values() method. Sometime’s we need to create array from object values and that’s why we simple method Object.values() interface User { id: number; name: string; domain?: string; age?: number; isActive?: boolean; } let user: User = { id: 1, name: "infinitbility", domain: "infinitbility....

April 9, 2022 · 1 min · Infinitbility

How to convert object to array in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert object to array in typescript, here we use some javascript Objects method like Object.keys() method. Sometime’s we need to create array from object we have to iterate a object. interface User { id: number; name: string; domain?: string; age?: number; isActive?: boolean; } let user: User = { id: 1, name: "infinitbility", domain: "infinitbility.com", age: 2, isActive: 1 }; let userDetail = []; const resultArray = Object....

April 8, 2022 · 1 min · Infinitbility

How to convert string to date in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! Today, I’m going to show you how to convert string to date object in typescript, here we will use new Date() method to convert date string to date. Let’s start the code. Suppose, you will get '1968-11-16T00:00:00' this type of string from api and want use as a date then you have to pass this string in date object like this new Date('1968-11-16T00:00:00')....

April 6, 2022 · 1 min · Infinitbility

How to define array of objects in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! This tutorial is part of the below series. TypeScript define variable How to define type in typescript? How to define array in typescript? How to define object in typescript? How to define array of objects in typescript? Let start Part 3: How to define array of objects in typescript? To create an array of objects, we will combine our Second and third tutorials, Here we have to define object property type and use it with in array data type....

March 29, 2022 · 1 min · Infinitbility

How to define object in typescript?

Hi Friends 👋, Welcome to Infinitbility ❤️! This tutorial is part of the below series. TypeScript define variable How to define type in typescript? How to define array in typescript? How to define object in typescript? How to define array of objects in typescript? Let start Part 3: How to define object in typescript? In this tutorial, we will create objects in typescript, but before creating objects we have to write their property data type....

March 28, 2022 · 1 min · Infinitbility