Top Programming Blogs to Read in 2024

Shohag

Published Fri 01, 26

The goal of this handbook is to quickly introduce you to the basics of JavaScript so you can start programming applications.

Instead of covering all the theories and concepts of JavaScript, I'll be teaching you only the most important building blocks of the language. We'll cover things like variables, data types, functions, objects, arrays, and classes. You'll also learn how to mix them all to build a small but solid program.

We're also going to leave out HTML, CSS, and using JavaScript in the browser. This tutorial focuses only on JavaScript as a programming language and uses the terminal to run the code.

This tutorial also has exercises for each section which gives you time to practice what you learned and "drill" the knowledge into your brain.

This handbook is completely free right here in this webpage. If you want the Kindle or paperback version of this tutorial, you can pay a small fee for it. It'll help support me in creating an in-depth JavaScript Tutorial that will help you build a complete web application.

Table of Contents 1 - JavaScript Introduction

Why learn JavaScript

JavaScript vs Java

2 - How to Set Up Your Computer

How to Install VSCode

How to Install Node.js

3 - Quick Console Introduction

4 - Time to Say Hello World!

5 - JavaScript Code Structure

Statements

Comments

Execution Flow

Exercise #1

6 - JavaScript Variables

Variable naming

Constant variable

The var keyword

Exercise #2

Summary

7 - JavaScript Basic Data Types

Strings in JavaScript

Numbers (integers and floats) in JavaScript

Booleans in JavaScript

Undefined in JavaScript

Null in JavaScript

8 - Type conversion and coercion

Type coercion

Type coercion rules

Why you should avoid type coercion

9 - Operators in JavaScript

Arithmetic operators

The assignment operator

The comparison operators

Logical operators

The typeof operator

Exercise #3

10 - JavaScript Arrays

Array index position

Special methods for array manipulation

Exercise #4

11 - Control Flows (Conditionals) in JavaScript

The if...else statement

The switch...case statement

The switch statement body

Switch statement use cases

Exercise #5

12 - Control Flows (Loops) in JavaScript

The for statement

When to use the for loop?

The while statement

When to use the while loop?

Exercise #6

13 - Functions in JavaScript

How to create your own function

Function parameters and arguments

Default parameters

Default parameters and null

The return statement

Variable scope

The rest parameter

Arrow function

Single and multiline arrow functions

Arrow function without round brackets

Arrow function doesn't have arguments binding

How to convert a normal function to an arrow function easily

Exercise #7

14 - Objects in JavaScript

How to access object values

How to add a new property to the object

How to modify object properties

How to delete object properties

How to check if a property exists in an object

Exercise #8

Final Exercise: Build a Cash Register Machine

Conclusion

Solutions

1 - JavaScript Introduction JavaScript was created around April 1995 by Brendan Eich. At the time, he was working to develop a browser for a company called Netscape. He was told that he only had 10 days to design and code a working prototype of a programming language that could run on the browser.

He needed to create a language that appealed to non-professional programmers like Microsoft Visual Basic.

The reason he was given only 10 days was that Netscape needed to release its browser, which at the time was in competition with Microsoft.

In the beginning, JavaScript was not as powerful as it is today, since it was originally designed to add interaction and animation for web pages. It wasn't until 2005 when jQuery and AJAX were released that JavaScript began to be used in every website.

People simply didn't have an easy alternative to jQuery and AJAX for DOM manipulation and sending asynchronous requests. Plus, an active community of JavaScript developers kept adding new features to the library.

Then Google launched its modern Chrome browser, and Facebook started getting more people online. JavaScript began to grow to accomodate the ambitions of these giant internet companies.

Browsers began developing APIs that you could use in JavaScript. JS could retrieve information such as IP addresses and geographic locations from the browser, adding more power to internet companies to localize the features of their websites.

Then another innovation happened to make JavaScript even more powerful.

A server-side environment named Node.js was released in 2009, allowing JavaScript to run on the server side like PHP, Java, Python, Ruby, and many more. It also enabled devs to develop full-stack web applications using only JavaScript.

Today, JavaScript is a language that can power the web, desktop, and mobile applications.

Here's a quote from Tim O'Reilly, the founder of O'Reilly Media:

Learning JavaScript used to mean you weren't a serious developer. Today, not learning JavaScript means the same thing.

Learning JavaScript is now critical for people who want to be web developers.

Why learn JavaScript? There are 4 good reasons why you need to learn and deeply understand JavaScript:

JavaScript is the only language that works in the browser

It's fairly easy to learn (but hard to master)

It's an essential language for making web applications

There are many career opportunities for JavaScript devs

Learning JavaScript opens tremendous opportunities where you can be a frontend, backend, or mobile developer.

Basically, learning JavaScript is a gateway to career improvements in tech.

JavaScript vs Java In the beginning, JavaScript was actually named LiveScript. It was renamed to JavaScript because Java was a very popular programming language.

Since most software developers were already familiar with Java, the name JavaScript was thought to help in marketing JavaScript as a great programming language and draw the interest of developers at the time.

Just to be clear, JavaScript and Java are two completely different programming languages. You don't need to know Java to learn JavaScript (or the other way around). :)

2 - How to Set Up Your Computer To write a program using JavaScript, you need to install 2 free tools that are available for all operating systems.

The first tool to install is Visual Studio Code.

How to Install VSCode Visual Studio Code or VSCode for short is a text editor program created for the purpose of writing code. Aside from being free, VSCode is open source and available on all major operating systems.

You can use VSCode on Windows, macOS, and Linux, so if you don't have a text editor on your computer, I recommend that you install VSCode here.

Now that you have a text editor to write JavaScript code, you need a software to run JavaScript code. Let's install Node.js next.

How to Install Node.js To run JavaScript outside of the browser, you need to install Node.js, which is essentially a JavaScript runner.

Simply go to the Node.js website at nodejs.org and download the latest LTS version for your computer. Once the download is complete, install it on your system.

You need to run Node.js using the console, so open your command line or terminal application and run the following command:

node -v This command will output the version of your freshly installed Node.js into the console.

3 - Quick Console Introduction The console is a text-based interface that you can use to type and run commands on your computer. On Windows, it's called the Command Line. On macOS and Linux it's known as the Terminal.

You're not going to use all the commands available within the console. In fact, you only need to know 7 basic commands to help you run JavaScript code.

First, open the console program on your computer and type the pwd command:

pwd This is the command you use to find out which directory your terminal is currently on. pwd is short for print working directory.

To change the working directory, you need to run the cd command.

Here's an example to move into a child directory:

cd directory_name/directory_name To move up to a parent directory, you specify .. next to the command:

cd .. To go up more than one directory, use ../..

To clear your console from previous commands and output, use the clear command:

clear To print out the list of files and directories in the current directory, run the ls command:

ls To create a new file, use the touch command followed by the file name and extension:

touch index.js The command above will create a new JavaScript file named index.js on the current working directory.

Comments (0)

Likes (0)

Login to react or comment on post