Difference between write()
and writeln()
:
<!DOCTYPE html> <html> <body> <p>Note that write() does NOT add a new line after each statement:</p> <pre> <script> document.write("Hello World!"); document.write("Have a nice day!"); </script>/*from w ww. j a v a2 s.c o m*/ </pre> <p>Note that writeln() add a new line after each statement:</p> <pre> <script> document.writeln("Hello World!"); document.writeln("Have a nice day!"); </script> </pre> </body> </html>
The writeln()
method is identical to the document.write()
method.
It writes a newline character after each statement.
Parameter Values
Parameter | Description |
---|---|
exp1, exp2, exp3, ... | Optional. What to write to the output stream. |
Multiple arguments can be listed and they will be appended to the document in order of occurrence
The writeln()
method return No value.