Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Convert Objects to Primitive Data Types Manually</title> </head> <body> <script> let arr = [1, 2, 3]; document.write(arr.toString() + "<br>"); // Prints: "1,2,3" let d = new Date(2018, 5, 24); document.write(d.toDateString() + "<br>"); // Prints: date like Sun Jun 24 2018 00:00:00 document.write(d.valueOf()); // Prints: 1529778600000 </script> </body> </html>