We’ve seen how JS can be used in three ways in the previous post.
We’ll now learn the DOM Model and how to use comments in JS.
But before, someone asked me why we need to specify type in the script tag. It’s because JS is not the only scripting language available, there are different languages available (ASP, PHP and so on) and different languages need to be processed differently. So we need to tell the browser which language is being used to help browser process page easily.
Comments in JS
//Single Line Comment.
document.write("<br>It's easy and you can learn it too!")
/* Multi line comment 1
Multi line comment 2 */
Try It Yourself
Please note that JS comments only work within the <script> tag or in the .js file.
The DOM Model
When we used document.write to print our custom message on the screen, we were actually using the DOM model to do so. The document is an object here and is accessed to write any message.
DOM is an abbreviation for Document Object Model. The HTML DOM defines a standard set of objects for HTML, and a standard way to access and manipulate them. But DHTML is about using DOM to access and manipulate HTML elements.
You can use Adobe DreamWeaver, Sublime or any other text editor you prefer to code JS. Notepad (Windows) is also a good choice.
I personally prefer Sublime Text 3.
If you want the above mentioned software, just fill in the Contact Us form on our site and hit submit!
Stay connected to see JS Basics in upcoming posts.
We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.
If you liked this article, then please like our Facebook page.