Which of the following is a valid JavaScript function to output "Hello, World!" to the console ?
Tripura Public Service Commission - 2025,
Answer: C
The valid function is console.log("Hello, World!").
In JavaScript, console.log() writes a message to the browser's or Node.js console, and is the standard way to print debugging output.
console.print, log.console and alert.console do not exist. (alert() on its own shows a pop-up box, not console output.)
Related methods are console.error() and console.warn(), which write error and warning messages.
Please log in or register to report this question.