
Learn JavaScript quickly by building fun, interactive and dynamic web app, games, and pages.
JavaScript is an amazing multi-functional language that is used a lot for web development (among other things). Any interaction that happens on web pages is JavaScript in action. In fact, all modern browsers understand JavaScript-and soon you will understand it too.
This book deals with everything you need to know to create JavaScript applications and use JavaScript on web pages. By the time you finish this book, you’ll be capable of creating interactive web pages, dynamic applications, and a lot more as you 50 progress on your professional JavaScript journey!
Why should you learn JavaScript?
There are many reasons why you should want to learn JavaScript. JavaScript originates from 1995, and is often considered the most widely used programming language. This is because JavaScript is the language that web browsers support and understand. You have everything you need to interpret it already installed on your computer if you have a web browser and text editor. There are better setups. however, and we will discuss these later in this chapter.
It is a great programming language for beginners, and most advanced software developers will know at least some JavaScript because they will have run into it at some point. JavaScript is a great choice for beginners for a number of reasons. The first reason is that you can start building really cool apps using JavaScript sooner than you could imagine. By the time you get to Chapter 5. Loops, you will be able to write quite complex scripts that interact with users. And by the end of the book, you will be able to write dynamic web pages to do all sorts of things.
JavaScript can be used to write many different types of applications and scripts. It can be used for programming for the web browser, but also the logic layer of code that we cannot see (such as communication with the database) of an application can be programmed in JavaScript, along with games, automation scripts, and a plethora of other purposes. JavaScript can also be used for different programming styles, by which we mean ways to structure and write code. How you would go about this depends on the purpose of your script. If you’ve never coded before, you may not quite grasp these concepts, and it’s not entirely necessary to at this stage. but JavaScript can be used for (semi) object-oriented, functional, and procedural programming, which are just different programming paradigms.
There are a ton of libraries and frameworks you can use once you get the basics of JavaScript down. These libraries and frameworks will really enhance your software life and make it a lot easier and possible to get more done in less time. Examples of these great libraries and frameworks include React. Vue.js, jQuery, Angular, and Node is. Don’t worry about these for now, just see them as a bonus for later. We will cover some of them briefly at the very end of this book Finally, we’ll mention the JavaScript community. JavaScript is a very popular programming language, and many people are using it. As a beginner in particular. there won’t be a problem for which you cannot find a solution on the internet.
The community of JavaScript is huge. The popular Stack Overflow forum contains lots of help for all sorts of coding issues and has an enormous section on JavaScript You’ll find yourself running into this web page a lot while googling problems and tips and tricks.
If JavaScript is your first programming language, you are new to the whole software community and you are in for a treat. Software developers, no matter the language. love to help one another. There are forums and tutorials online and you can find answers to almost all your questions. As a beginner, it can be hard to understand all the answers though. Just hang in there, keep trying and learning, and you will understand it soon enough.
How does the browser understand JavaScript?
JavaScript is an interpreted language, which means that the computer understands it while running it. Some languages get processed before running, this is called compiling, but not JavaScript. The computer can just interpret JavaScript on the fly. The “engine” that understands JavaScript will be called the interpreter here.
A web page isn’t just JavaScript. Web pages are written in three languages HTML, CSS, and JavaScript.
HTML determines what is on the page; the content of the page is in there. If there is a paragraph on the page, the HTML of the page contains a paragraph. And if there is a heading, HTML was used to add a heading, and so forth. HTML consists of elements, also called tags. They specify what is on the page. Here is a little sample that will create a web page with the text Hello world on it:

CSS is the layout of the web page. So for example, if the text color is blue, this is done by CSS Font size, font family, and position on the page are all determined by CSS JavaScript is the final piece in the puzzle, which defines what the web page can do and how it can interact with the user or the backend.
When dealing with JavaScript, you will come across the term ECMAScript sooner or later. This is the specification or standardization for the JavaScript language. The current standard is ECMAScript 6 (also referred to as ES6). Browsers use this specification to support JavaScript (in addition to some other topics such as Document Object Model (DOM), which we’ll see later). JavaScript has many implementations that might differ slightly, but ECMAScript can be considered the basic specification that the JavaScript implementation will definitely include.
Using the browser console
You may have seen this already, or not, but web browsers have a built-in option to see the code that makes the web page you are on possible. If you hit F12 on a Windows computer while you are in the web browser, or you right-click and select Inspect on macOS systems, you will see a screen appear, similar to the one in the following screenshot.it might work slightly differently on your browser on your machine, but right-clicking and selectin g inspect generally does the trick:

This screenshot contains multiple tabs at the top. We are now looking at the eleme tabs, which contain all the HTML and CSS (remember those?). If you click on the console tab, you will find at the bottom of the panel a place where you can insert some code directly. You may see some warnings or error messages in this tab T is not uncommon, and don’t worry about it if the page is working.
The console is used by developers to log what is going on and do any debugging Debugging is finding the problem when an application is not displaying the desired behavior. The console gives some insights as to what is happening if you log sensible messages. This is actually the first command we are going to learn.
console.log(hello world!”);
If you click on this console tab, enter the first JavaScript code above, and then hit Enter, this will show you the output of your code therein. It will look like the following screenshot:

You will be working with the console.log() statement a lot throughout the book in your code to test your code snippets and see the results. There are also other console methods, such as console. table(), that create a table when the inputted data can be presented as a table. Another console method is console.error(), which will log the inputted data, but with a styling that draws attention to the fact that it’s an error.