Javascript - intro

in #javascript4 years ago

Hello again!

Previously, I wrote about how I study programming from scratch on IvanOnTech Academy. I also wrote that in order to understand Javascript, we first have to get a bit into HTML and that's wthat the previous article is about.
This time, we will start getting into actual programming!

What is a program? It is a set of precise instructions that tell a computer what to do - "take this data and do this action with it". A computer can only take an instruction and execute it. The magic happens because it can execute it in a great speed and get on the next one.

Each command is simple and straight-forward. However, to actually build something, we have to combine loads of such commands and assemble them in long codes. These codes then may become difficult to understand. To make commands readable and understandable for a programmer, different programming languages have been created and one of them is the famous Javascript, or sometimes we may hear the term ECMAscript, which is basically another word for the same thing.

If you operate in Javascript, you will be doilg a lot of console.log. It brings the output of a command on the console.
What is a console?
It is a place where you can log information during the Javascript development process. You can use the console itself for viewing command outputs. You can interact with a web page by creating new elements.
Working on console, though, doesn’t change the .html document, so when you reload a page, it will return to its original state.
Each browser has a console. Below is how we can access it in Google Chrome, or the faster and less snitchy Brave. (Yes, it is a referral link and yes, I might get a buck if you download Brave through that. But seriously, if you're not using Brave already, try it, it is amazing! Built-in add-block, built-in torrent, and you can earn BAT just by seeing the background on the new tab page!)

image.png

...and click Console tab.
Or, right-click anywhere on the page and click Console tab on the panel that opens.

Although we cannot change the .html file through console, we can change how the webpage appears right now. We can define style parameters like background, font size and color, etc in Javascript on the console and it will change the HTML code that browser reads at that moment.
If we do this in the Console tab:

image.png

This happens in Elements tab (that is, in HTML code):

image.png

You can also create new elements and then append them as “child” to body:

image.png

which adds this to HTML:

image.png

One thing to mention is that Javascript is case sensitive. appendChild works, appendchild doesn’t.

That's it for now. Thanks for reading and until next time, when we will get into operators!

Sort:  

Congratulations @chappy! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You received more than 10 upvotes. Your next target is to reach 50 upvotes.

You can view your badges on your board And compare to others on the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!