JavaScript — Beginner’s Guide
Greetings! Welcome to JS. Here I am going to give a warm welcome to JavaScript explaining its unique, famous features. Also, I will compare JavaScript with other languages mentioning its ups and downs. Therefore if you are already a programmer and looking forward to moving to JavaScript, this blog can help you. This blog is for programmers with some experience in any programming language.
Here are the main topics we discuss here
· Little about history
· Basic syntaxes
· Object-oriented
· Closures
· Single-threaded non-blocking
· Node
Little about history
JavaScript is not its first name. It was initially named LiveScript and was born in 1995. At the end of the same year, it was named JavaScript. The language was created by Netscape to add dynamic nature to websites. Initially, several variations of language were born. For example, once Microsoft reverse engineered JS and created a language called Jscript that supports only Internet Explorer.
Around this time European Computer Manufacturers Association (ECMA) started to give standards for JavaScript. Those standards were written in a paper and published as ECMAScript. So all the browsers can design JavaScript engines according to these standards.
From 2004 things started to be good for original JavaScript because the Mozilla Firefox browser was released. Mozilla joined with ECMA, Adobe and collaborated on creating ECMAScript. In 2005 Ajax was added to ECMAScript. With Ajax, JS could load data from the background and that stopped page reloads.
In 2008 Chrome came with V8 JavaScript engine. With this Just in Time Compiler (JIT) for JavaScript came out. In 2009 all these parties came together and released ECMAScript 5 (ES5) 2009. This was a breaking change for JavaScript releasing features like ‘use strict’, array functions, getters, and setters, etc.…. Same year Node.js was created and JavaScript could be run outside the browser.
Basic Syntaxes
JavaScript is a high-level, weakly typed, dynamically typed, object-oriented programming language.
Weakly typed — In JS you can add a number to a string. At that time according to the case, the string will be converted to a number, or the number will be converted to a string. When the type of variables are converted implicitly at run time and when it is not restricted to do operations between different types of variables when they are not implicitly allowed, it is called weakly typed. In programming languages like Java, C#, Python you cannot add a string and a number (variables of different types) unless they are allowed to implicitly. Those types of languages are called strongly typed languages.

Dynamically typed — the type of variable can be changed anytime. You can assign values of any type to any variable. PHP and Perl are also dynamically typed languages. In languages like Java, C#, Dart, Python, each variable has a specific type and you have to define their types when declaring the variable. You can assign only the values with the same type as the variable to the variable. They are statically typed programming languages.

Object-Oriented — every variable in JS is an object. In a programming language like C/C++ integer (int) variables do not have properties or functions. They are pure integers. But in JS, a variable of type number have several properties and functions.

Object-Oriented (OO)
JS was an OO language from the beginning but it was lacking classes. In most other languages when it comes to OOP, classes are the blueprint for objects (C#, Java, Dart, VB.NET, C/C++). JS has something called an object constructor which has the general function definition syntax. You can create objects from this function just like in other languages objects are created from classes.

Inheritance also works differently but the concept is the same. In previously mentioned programming languages you can use the keyword extends to inherit a class from another class. In JS you have a prototype-based system to add extra properties or functionalities to an object constructor.

If you are familiar with programming languages like Java or C# you may have probably seen interfaces. JS does not have interfaces because the language is dynamic. Functions from an object can be removed or added at any time.
Anyway, with ECMAScript 2015 (ES5), normal class syntax with some other common object-oriented concepts and syntaxes came to JS. With ES5 above example can be written as follows,

Closures
Initially, JavaScript variables did not have a closed scope. All variables had a global scope. This means a variable declared inside a if, switch, for, while can be accessed from outside of the block.

Then const and let keywords were introduced. If a variable is declared using any of these keywords, they are available only inside the block. The difference between const and let keywords are, variables declared using const keywords cannot be reassigned while variables declared with let keyword can be reassigned.

The closure is a function having access to variables of its parent function even after the parent function is destroyed. This feature sounds cool. But actually how to use it. Check the following example.

Single-threaded, non-blocking
When there are several threads, the program can assign each thread a task. For example, create a thread to read data from a file, create another thread to get user input, etc.… while the application is running on the main thread. Threads can work parallel. Therefore one task does not have to wait until another task is over. In other words, multithreaded programming languages are non-blocking.
This is cool, but the title says single-threaded and non-blocking. Languages like C# and Java are multithreaded but not JavaScript. Okay. But how non-blocking?
JS has only one call stack and it places each statement in this stack and each statement in the call stack is executed one by one. The thing is functions like setTimeout, setInterval, promises, etc. are not part of JS. The APIs are provided by the environments like Node or browser. When the API has handled the given function it places the next necessary statements in a queue called Callback Queue. When the call stack is empty, JS checks if there are any statements in the callback queue and executes the statements in the callback queue in order. That is how JS handles multithreaded tasks.

Node
Node is a JavaScript runtime environment. A platform where JavaScript can be executed outside the browser. Node is using V8 which is also used by Chrome to execute JavaScript. Node provides more API to handle files, send and receive HTTP calls, etc.
The most famous products developed on Node are Google Chrome, MS Teams, and VS Code.