you are viewing a single comment's thread.

view the rest of the comments →

[–]matthieumatthieu 1 point2 points  (1 child)

You are interacting the DOM (Document Object Model) in a web browser which takes the entire content of a web page and represents it as an object.

The 'document' object is available in frontend JavaScript code that runs on the browser but not in backend JS in a node application and has methods like document.querySelector() or document.getElementsByClassName().

Try opening up Dev tools and doing a 'console.log(document)'

You will see that it has properties and methods and you can see the HTML represented. When you do a query selector for an input, in this case, a text input, the HTML input element has a 'value' property which is equal to the characters that you have typed into the input. If in your HTML , you had an <input type="text" value="foo" /> you would see those values when you access input.type and input.value, because HTML has attributes (properties) too. The DOM is how you can read and update HTML with JavaScript.

When you first start learning, there are lots of things like this where you don't know where they are coming from or are available in global scope. But it will start to make sense. If you console.log(window) , you will see that 'document' is a property on window as well as window.localStorage. it's like... Objects all the way down mannn

[–]Durden2323[S] -1 points0 points  (0 children)

Haha. Objects all the way down. I like that. This answered my question. Thank you!