Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Working with Strings and Finding Help

Kireeti K
Kireeti K
9,675 Points

What is a document here? and how a document and browser console becomes an object?

Hello, As mentioned in the video. A string, Document & Browser Console are objects. A document i guess the app.js is a document and console is where we see what JS is writing to the console for messages or errors. How come a document and Browser console becomes an object. Can anyone explain please.

Also what other objects exist in the JS?

Thanks in advance

2 Answers

Nathan Tallack
Nathan Tallack
22,159 Points

Right. Here goes.

When you are calling document.write(), you are modifying the HTML document that is calling your javascript. It will modify the document at the spot where the javascript was called.

So if you were to make a heading tag and then insert some javascript code there, either as raw script or as a link to the code, and that code went and executed a document.write('hello') then what would happen is the text hello would be inserted in between those <h1></h1> tags where you called the script.

The console method is just writing something out to your javascript console. Helps to debug your code. Regular web users would not see that because they don't normally display that console in their browser. Besides you should have that removed before you push your page out to the public. ;)

Finally, LOTS AND LOTS of object types are built in. And the crazy part, with object oriented javascript (you will learn later) you can make your OWN object types!!! :D

It is going to be a blast! Keep up the great work! :)

Kireeti K
Kireeti K
9,675 Points

Hello Nathan, Thanks for the very clear description.

Cheers!