0% found this document useful (0 votes)
7 views1 page

Number to String Conversion Guide

Uploaded by

bakhtawark085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Number to String Conversion Guide

Uploaded by

bakhtawark085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Convert Number to String</title>
</head>
<body>
<h1>Number to String Conversion Methods</h1>
<script>
let num = 123;

// 1. Using String() function


let str1 = String(num);
console.log("Using String():", str1, typeof str1);

// 2. Using .toString() method


let str2 = num.toString();
console.log("Using .toString():", str2, typeof str2);

// 3. Using Template Literals


let str3 = `${num}`;
console.log("Using Template Literals:", str3, typeof str3);

// 4. Using String Concatenation


let str4 = num + "";
console.log("Using String Concatenation:", str4, typeof str4);

// 5. Using JSON.stringify()
let str5 = JSON.stringify(num);
console.log("Using JSON.stringify():", str5, typeof str5);
</script>
</body>
</html>

You might also like