Thursday, May 19, 2022

JavaScript the Number method

To convert number in string & string in number;

First variables could be called var, let or const. The newwest is let and const, the const is hard to see where to use but if be the case is what is to suppose to be used and the let is for all the hours, when the cosnt is being an problem, const commonly you can't change the value, the name const is about constant constant is something that doesn't change, an variable could have the value changed for an addition or other operation, or the value change because the situation changed, was the hour was the user.

So convert number to string and string in number:

const isAString = '444';

const isANum = Number(isAString);

⚘⚘⚘⚘⚘⚘⚘⚘⚘⚘⚘⚘⚘

const isANum2 = 444;

const isAString2 = isANum2.toString();

Explanation the class Number and all inside are object or something pretty next but what is the difference of the two methods upper, the 1st the isAString isn't an object-Number so the method isn't common to the isAString, cos the conversion is because the isANum that is a number so is :

const isANum = Number(isAString), because the object-number is the variable that is being initialize and not the variable that I already have that is a string, so number with (=) say do my method conversion Number to what is between in parenthesys what is in parenthesys is the parameter and not the object from the family number.

And the second that is a number converted to string is isANum2.toString(); because the method converted inverse also is an method of the family Number, so now the variable that I am initializing haven't nothing about number what have something about the number is the variable that I already have, so the method have to be applied to the older variable that is from its familyso is isANum.toString();

because isANum2 is a number so is dot the method of his class and parenthesys, because methods you can see they have parenthesys in the end because they are methods and not because have something inside and is empty because doesn't have parameter because the causer of that change is assigned before the dot, you only could dot something that if what is before have that method, so is number.his-method(). Rute Bezerra de Menezes Gondim


No comments:

Post a Comment