最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the difference between write and writeln? - Stack Overflow

programmeradmin1浏览0评论

What is the difference between write and writeln?

I've searched in stackoverflow, but could not find about this. And I also searched Google where I can get the different sites results. But I believe that SO would give me the best description on these. Thanks.

What is the difference between write and writeln?

I've searched in stackoverflow, but could not find about this. And I also searched Google where I can get the different sites results. But I believe that SO would give me the best description on these. Thanks.

Share Improve this question edited Jan 20, 2014 at 13:40 Chris Ballard 3,7694 gold badges30 silver badges40 bronze badges asked Jan 20, 2014 at 10:58 Navin RauniyarNavin Rauniyar 10.6k14 gold badges46 silver badges70 bronze badges 1
  • 2 Why not read the manual page? – Ed Heal Commented Jan 20, 2014 at 13:41
Add a ment  | 

4 Answers 4

Reset to default 7

writeln adds a \n character to the end of the string. This almost never makes any noticeable difference when writing to an HTML document.

write and writeln are the same function. The only difference is that writeln adds a new line at the end of the text.

write() and writeln() methods have the same functionality

If you give for loop then it will be internally writeln method will break the line but in real-time we have no such outputs

because of windows.document.write(), windows.document. writeln() methods are the problem...if we want to break the line we have to use br, \n, or pre tag or you can use the para tag in the script.

We have no option with writeln() method to break the line.

In javascript, there is no much difference in write and writeln. When writing to an HTML document, this nearly never makes a difference. Writeln only increases the readability of the code.

发布评论

评论列表(0)

  1. 暂无评论