What is JavaScript?

alaa-samy

Alaa Samy

Posted on March 15, 2024

What is JavaScript?

Javascript is a programming language that can help to create dynamic pages and make it more interactive.
Javascript is described as prototype-based, high-level, multiparadigm, single-threaded, dynamic typing, and garbage-collected.


JavaScript is prototype-based

It means that JavaScript can create objects without defining its class

function Car (){
  this.color = 'red',
  this.wheels = 4
}

const firstCar = new Car();
Enter fullscreen mode Exit fullscreen mode

JavaScript is high-level

JavaScript is a high-level language because it's easy to understand, and it doesn't have to manage resources at all or deal with hardware and operating system.


JavaScript is multiparadigm

JavaScript is very dynamic and it supports various types of programming styles such as:

1. Imperative programming paradigm

It's a paradigm that focuses on how the program should perform, through a set of instructions to follow, and the computer does what you want like:

  • Object-oriented programming

  • Procedural code

const arr = [1, 2, 3, 4, 5]
const result = []

for (let i=0; i < arr.length; i++){
   result.push(arr[i] * 3)
}

console.log(result)
// [3, 6, 9, 12, 15]
Enter fullscreen mode Exit fullscreen mode

2. Declarative programming paradigm

It's a paradigm that focuses on what the program should accomplish without specifying the instructions on how to solve the problem like:

  • Logic language

  • Functional programming

  • Domain-specific language

const arr= [1, 2, 3, 4, 5]
const result = arr.map(num => num * 3)

console.log(result) 
// [3, 6, 9, 12, 15]
Enter fullscreen mode Exit fullscreen mode

JavaScript is single-threaded

It means that javascript can only execute one task, and each task must done and completed before the other task starts

function First() {
  console.log('First function');
}
function Second() {
  console.log('Second function');
}

First();
Second();
// First function
// Second function
Enter fullscreen mode Exit fullscreen mode

JavaScript is dynamic typing

JavaScript interpreter assigns a type to a variable at a run time based on the value assigned to that variable


JavaScript is garbage-collected

The Garbage collector is an algorithm inside javascript engines, it automatically frees up memory by removing unused objects, which can help to prevent memory leaks.


I hope you find something useful in this article

😊Happy coding!

💖 💪 🙅 🚩
alaa-samy
Alaa Samy

Posted on March 15, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related