Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Using For Loops with Arrays

Sascha Lamparter
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Sascha Lamparter
Front End Web Development Techdegree Graduate 15,570 Points

What excatly does the print function?

Is it always putting HTML virtualy in your HTML-document? Or is it just putting data on the website - but if it is second, what the difference to document.write? Thanks a lot.

Hi Sascha, did I understand your question? or was there something else about document.write and the print function. I know he does it a few different ways. document.write is not used any more except in testing. there is a print function Dave uses with document.write, but he later changes document.write to innerHTML. I think the point he's making is by using functions, if a better way to do something comes out, you only have to change one function.

2 Answers

  • Is it always putting HTML virtualy in your HTML-document? I believe that is exactly what it is doing. Or maybe it's something like: it provides data to the browser that interprets it as html in the document. Some one else could probably answer better, but I liked your question.
  • difference to document.write? document .write always loads a certain way and displays at a certain place. I forget the exact details of that. But: when you use innerHTML, which I believe is what I believe you are referring to, you have complete control over where the html is placed and it doesn't interfere with how the page loads. (document.write does)