Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Copy by Value</title> </head> <body> <script> var message = "Hello World!"; var greet = message; // Assign message variable to a new variable greet = "Hi, there!"; document.write(message + "<br>"); // Prints: Hello World! document.write(greet); // Prints: Hi, there! </script> </body> </html>