Write your first Javascript Code

Photo by Nebular on Unsplash

Write your first Javascript Code

with a little bit of history about Netscape

Javascript as you might have already known is one of the most loved high-level programming languages out there and popular among beginners as well. So having a strong foundation of Javascript is essential to fully understand the language.

Let's get started

Boilerplate

  1. Open VS Code

  2. Create a new index.html file

  3. Press the "!" button to autogenerate boilerplate

  4. Your HTML Boilerplate is ready

We are not going to use any CSS for this project and instead focus on javascript

<Script> Tag

Within the body of your html, open a new script tag just before the body tag ends

<script>
</script>
</body>
</html>

document.write Method

Within the script tag add the following code

<script>
document.write("This browser is version " + navigator.appVersion)
</script>

Let's analyze it

Here the 'document' refers to the Document Object Model (DOM) of the HTML.

We are accessing the "write" method of the "document" class. If you are are yet to come across class, objects and methods, that is totally fine.

The "document.write" method as the name suggests is used to write anything on to the HTML DOM

document.write("Hello Browser DOM")

you can play with it with any string you want.

Let's have some fun by knowing more about the browser

Navigator Object

The Navigator object in Javascript is used for querying details about the browser in which the script is currently running in.

appVersion

The appVersion method in the navigator object is used to return details about current browser version.

document.write("This browser is version " + navigator.appVersion)

chrome

Firefox

appName

The appName method in the navigator object is used to return details about current browser name.

document.write(navigator.appName)

You will get the following name "Netscape" as output regardless of Chrome, Firefox or Edge.

Netscape

What is Netscape?

Well the history of Netscape, Javascript and the browsers are interwind in a way

Read More...

Netscape - https://en.wikipedia.org/wiki/Netscape

Netscape Navigator - https://en.wikipedia.org/wiki/Netscape_Navigator

Netscape Browser - https://en.wikipedia.org/wiki/Netscape_Browser