JavaScript

Introduction to JavaScript

Javascript is a scripting language that was essentially made for client-side programming applications. However, later the popularity of JavaScript led to developers of JavaScript adding more and more functionalities to JavaScript, eventually leading to JavaScript becoming a language for server-side coding.

JavaScript was created around 27 years ago (at the time of this writing) in 1995, and in just two years, it quickly became an ECMA standard for web browsers. Now the term ECMAScript is often heard by many new programmers when they start out in JavaScript, and they get confused. When JavaScript became an EMCA standard, the name versions of JavaScript started to come out named “ECMAScript,” and different versions got abbreviated down to ES1, ES2, and so on.

Testing out JavaScript

Sometimes, when starting out in programming, he doesn’t want to fully commit to one programming language. Well, JavaScript can be tested on any modern-day web browser by simply heading inside its console and running commands there, and then one can decide to commit or not.

To do this, open up developer tools (or similar according to your browser) of your browser

And then head over to the console tab:

Since JavaScript is an ECMA standard for web browsers, the web browsers can execute JavaScript code snippets without requiring any external environment settings.

In the console, type the following lines:

console.log("Hello, This is My First JavaScript Test Run");

Hit enter, and the console will show the following:

The console.log() statement is a function of JavaScript that is used to print out data onto the terminal of either your browser or your code editor.

Running Some Basic JavaScript Commands

In the console, variables can easily be created by simply typing the name or identifier of the variable, and then the user can give them some value. However, the better approach is to declare the type or, more precisely, the variable’s scope by using the keywords like var or let. Use the following lines to create values and store different values inside them:

var name = "John Doe";

var age = 22;

isEmployed = true;

After this, these values are now stored in the temporary memory of the browser. You can alert the user with the help of the alert() function to display a dialogue box on the browser’s window (Yes, on top of the browser’s tab window) with the following line:

alert("Your Name is as : " + name + " age is " + age );

Hitting Enter would display the following alert box:

This was possible because JavaScript was mainly built for HTML manipulations which included working with different objects of the browser.

You can also take the input from the user using the prompt() method and store that input inside a variable like

var city = prompt("Which City Do You Live In" + name);

Hitting Enter will display the following alert box with an input field like:

So fill in the answer in the input field like:

After that, you can again use the alert box to display the user’s city on the browser’s window with the following statement:

alert("So you are from " + city);

With this, the browser will show the following alert box:

Anyways this was it for the basic introduction of JavaScript

Wrap-up

JavaScript, commonly referred to as the scripting language for websites, is a portable, cross-platform (with packages now supporting multiple platform development), interpreted computer language. It was mainly built for web page manipulations and building. However, it is widely used in non-browser situations and is well known for web page building.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.