Let’s start with a simple introduction of JavaScript, an easy to learn and powerful scripting language.

JavaScript (often shortened to JS) is a lightweight, interpreted, object-oriented language with first-class functions,
and is best known as the scripting language for Web pages, but it’s used in many non-browser environments as well.
It is a prototype-based, multi-paradigm scripting language that is dynamic, and supports object-oriented, imperative and functional programming styles. JavaScript runs on the client side of the web, which can be used to design / program how the web pages behave on the occurrence of an event.

If you have finished learning HTML and CSS you might find the beginning of JavaScript a bit overwhelming, to process or to adopt to. Learning HTML and CSS is fun, you get to see what you write, visualize your work as you go, while with JavaScript we don’t get that. Learning the basic of JavaSrcipt will be fundamental of understanding the language and in future building more exciting stuff like games, full applications, live-chats … anything exciting you have seen in the browser.

So buckle up will get to that i promise.

One of the analogy is that HTML is often consider the noun or the nouns on the page and CSS is the adjectives that are going in and styling or describing those nouns. And then the action or verbs are JavaScript.

Before we jump into writing JavaScript code in a syntax we gonna start by figuring out where we write the code.
In Chrome one of the places we can do that is the developer console. To get here we can right click on the mouse and go to Inspect element then Console, we can also select the chrome menu icon Menu>More Tools>Developer tools and there is a shortcut Ctr+Alt+J (or F12) on the keyboard.

This a place we can go and write JavaScript in the browser. Developers do not write full JavaScript applications in this console here, just like developers do not write an entire style sheet in the browser using the CSS inspector, what you use it for is interacting with CSS or understanding how something works or testing something out and than you go and make the changes in your CSS file. So down the line we will do the same with JavaScript, we will use the console to play around with things, to test things out but then we will actually implement a full JS file that persist and that we save to our machine rather than just in the browser.
In the JavaScript console you can enter any code, it doesn’t matter what the code does, once you hit enter the code will be executed. For example, the code below displays an alert box with a specified message (you can write anything you want here) and an OK button.

 

At the beginning we won’t be using any HTML or CSS, we will be focusing on pure JavaScript, understanding the most important components of basic JavaScript that will help us in building the bad-ass stuff down the line.

So in the next part we will demonstrate how to write JS in separate file that we can then include in an HTML file and get to run in the browser. So rather to write the code in to the console which only exists until we refresh the page or close the window we can now get things to persist and save in a file.

 

 

Spread the love

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *