#JS from Start- JavaScript Type Conversion

avatar

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



0
0
0.000
0 comments