“4.2. Typumwandlung Typ” Code-Antworten

4.2. Typumwandlung Typ

/*What happens if we attempt to convert a string to a number, and the 
string doesn't directly represent a number?*/

console.log(Number("23bottles"));

//NaN
Tough Tortoise

4.2. Typumwandlung Typ

/*The Number function can take a string and turn it into an integer. 
Let us see this in action:*/

console.log(Number("2345"));
console.log(typeof Number("2345"))
console.log(Number(17));

//2345
//number
//17
Tough Tortoise

4.2. Typumwandlung Typ

/*The type conversion function String turns its argument into a string. 
Remember that when we print a string, the quotes may be removed. 
However, if we print the type, we can see that it is definitely 
'string'.*/

console.log(String(17));
console.log(String(123.45));
console.log(typeof String(123.45));

//17
//123.45
//string
Tough Tortoise

Ähnliche Antworten wie “4.2. Typumwandlung Typ”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen