Basic Javascript Series

Basic Javascript Series

laptop g9d964cda0 1280 1

Javascript is the language that is running on the browser. Did you ever like a post on Facebook or have ever done a comment on social media? Have you ever uploaded an image to Instagram? Have you ever uploaded shorts on youtube? Javascript is the language running behind all these works. Now all these things are happening through manipulating the DOM. What is DOM? DOM is a document object model. Whenever we are interacting with a web app like Facebook, Instagram, Youtube, or Twitter to do the CRUD operation that is created, read, update, and delete operation we are using javascript to manipulate the DOM. For example, If you have commented on a post you can see immediately the post has appeared in the list. That is the dom is modified now to enter the comment made by you. If you like a post number of likes is increased by one. The DOM is here again changed. We need javascript to manipulate the DOM. Any kind of interactivity made by the user in a web app is happening because of Javascript.

Now all the things that are happening in front of your eyes because of the client-side javascript. It is also used on the server side as well. We will learn the basics of javascript in this series so that we can apply it anywhere.

In Javascript, variables are used to store data. Javascript offers various data types like numbers, strings, booleans, arrays, and objects. Functions are used to reuse code. If-else statement is used to make decisions based on certain conditions. Loops are used for repetitive tasks.

If you want to follow along with this series you have to install node js, Git, and visual studio code editor.

Installation of Node js

To install Node js go to https://nodejs.org/en and download it. Follow the prompt in the installation wizard and install node js. To check whether it is installed or not go to your terminal and type

node -v

If you get the version of node you have installed node js. Congratulations.

You may be now confused about why should I use node js to execute javascript whereas it is used on the client side in the browser. Today node js is the server-side implementation of the javascript which is used in all the server-side implementations. If you know the popular react library which was developed by meta, it is also installed through node js. Express js is a node js server that is very popular in the world. NPM is the node package manager that is used to install useful packages made by other developers.

Installation of Visual Studio Code

Go to the link https://code.visualstudio.com/ and download VS code which is the most used code editor for web development. Follow the setup wizard and install vs code.

Installation of Git Bash

If you don’t have Git installed on your computer install it from https://git-scm.com/downloads

Write your first Javascript code

Now after doing all these steps open VS Code and create a file called index.js by typing the following command in your terminal. VS Code has its integrated terminal. At the top of the screen, you will get the menu bar. Click Terminal and then New Terminal. A terminal window will open. Choose from the drop-down Git Bash. Type

touch index.js

You have created an index.js file and as it is open in your VS Code, type

console.log("Hello World")

Now in the terminal type

node index.js

The output will be

Hello World

If you have done this far that means you are now ready to go to the next step. In the next chapter, you will learn about variables and data structure. What they are and what they are used for. Get the next article here.

Leave a Comment