What is JavaScript ?
JavaScript is a high-level prototype-based object oriented Multiparadigm, interpreted or just in time compilated dynamic, single Treaded, garbage collected programming language with first-class functions and a non-blocking event loop concurrency module.
๐คฏDon't Worry Let's break above definition into points.๐
- High-level
- Garbage-Collection
- Interpreted or just in time compiled
- Multi-paradigm
- Prototype-based object-oriented
- First class functions
- Dynamic
- Single-Threaded
- Non-blocking event loop
๐Now Let's discuss each point in detail.
1. JavaScript is High-Level
๐กEvery program that runs on our computer needs some hardware resources such as memory and the cpu to do its work.
๐กThere are low level languages like C where we have to manually manage these resources.
On the other side we have high level languages like python and JavaScript where we do not have to manage resources at all.
๐ก Because these languages have so called abstractions that take all of the work away from us.
2. JavaScript has Garbage-Collection
๐ก It is basically an algorithm inside the JavaScript engine that removes old, unused objects from the computer memory
๐ก JavaScript cleans our memory from time to time so that we don't have to do it manually in our code
3. JavaScript is interpreted or Just-in-time compiled
๐ก Computer processor ultimately understands 0 or 1 every single program needs to be written in binary language which is also called machine code.
๐ก That is not practical to right that's why we write human-readable code.
Like JavaScript which is an abstraction over machine code.
๐กBut this code eventually needs to be translated to machine code and that step can be either compiling or interpreting.
๐ก Above step is necessary in every single programming language.
๐ก Because no one write machine code manually. IN case of JavaScript This happens inside the JavaScript engine.
4. JavaScript is Multi-paradigm language
๐ก In programming a paradigm is an approach overall mindset of structuring our code. Which will ultimately direct the coding style and technique in a project that uses a certain paradigm.
๐ก Some popular programming paradigm are:-
- Procedural Programming
- Object-oriented programming (OOP)
- Functional Programming
5. JavaScript has prototype-based, object-oriented approach.
๐ก All most everything in JavaScript is an object except of primitive values.
๐ก But arrays, for example are just object.
๐ก Now, have you ever wondered why we can create an array and then use the push method on it
๐ก It's because of "prototypal inheritance". Basically we create arrays from an array blueprint which is like template and this is called the prototype.
๐ I will create a separate thread ๐งต on prototypal inheritance.
6. JavaScript is a language with first class function
๐กIn a language with first-class functions, functions are simply treated as variables. We can pass them into other functions, and return them from functions.
๐กWhich means functions are treated as regular variables
๐กSo, we can pass functions into other functions and we can even return functions from functions.
7. JavaScript is Dynamic
๐กJavaScript is a dynamic language which means dynamically-typed language
๐กIn JavaScript we don't assign data types to variables, instead they only become known when the JavaScript engine executes our code.
8. JavaScript is Single-Threaded
๐ก Before know what is single threaded we need to know about the "Concurrency Model"
๐ก Well "Concurrency Model" is a fancy term that means how the JavaScript engine handles multiple tasks happening at the same time.
๐ก JavaScript itself runs in one single-thread which means it can only do on thing at a time and therefore we need a way of handling multiple things at the same time.
๐กBy the way in computing a thread is like a set of instructions that is executed in computer's CPU
๐ก So basically, the thread is where our code is actually executed in a machine's processor.
๐กBut what if there is a long running task like fetching data from a remote server.
๐กWell it sounds like that would block the single thread where the code is running right.
๐ก But we don't want that. what we want is
๐ Non-blocking behavior and how do we achieve that. Well by using a so-called event loop. The event loop takes long-running tasks, executes in the background and put's them back in the main thread
๐ก This is in a nutshell JavaScript's non-blocking event loop concurrency model with a single thread

Top comments (0)