tykee avatar

#JS from Start- JavaScript Type Conversion

tykee

Published: 11 Aug 2020 › Updated: 11 Aug 2020#JS from Start- JavaScript Type Conversion

#JS from Start- JavaScript Type Conversion

I mentioned that I will be posting on the #Jsfromstart on Tuesday, Thursdays and Saturday, but I could not post last Saturday because I was pretty engaged. So, I am sorry for that. Last time, I talked about the data types which are the primitive and reference. I gave a clear explanation of the two. Today, I will write about Type conversion. It is all about taking a variable and changing the data type. There are situations you would do this and you should know how to do them.

So, let's initiate a variable.

Number to String

I console.log the variable, typeof and the length for strings and I I used toFixed for numbers. The images explains all.

Boolean to String

Date to String

Array to String

The toString() method

String to Number

Boolean to Number

Null to Number

parseInt() Method

parseFloat() Method

Type coercion

That will be it for today, I will talk about Number and Math objects in the next post.

Thank you.

cover imagetykee03.png

Leave #JS from Start- JavaScript Type Conversion to:

Written by

Dev | Content writer | Engineer |

Read more #tutorial posts


Best Posts From tykee

We have not curated any of tykee's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From tykee