DEV Community

Dhanush P
Dhanush P

Posted on

JavaScript Introduction

Introduction

  • JavaScript is a programming language used to create dynamic content for websites.
  • It's an interpreted language that executes code line by line.
  • JavaScript is a lightweight, cross-platform[TBD], object-oriented scripting language used to make webpages interactive.

History of JavaScript

  • In May 1995, Brendan Eich created JavaScript, a programming language, in just 10 days.
  • In 1995 Netscape Communications Corporation needed a way to make web pages more interactive and dynamic.
  • Brendan Eich was hired by Netscape to develop a new scripting language for this purpose.
  • The language was initially called Mocha and later changed to LiveScript.
  • In December 1995, LiveScript was renamed JavaScript, partly to capitalize on the growing popularity of the programming language Java.

Variables in JavaScript

  • A variable is like a container that holds data that can be reused or updated later in the program.
  • Variables are used to store and manage data in a program.

Variables: Declared using the keywords var, let, or const.

1. var Keyword

  • The var keyword is used to declare a variable.
  • It has a function-scoped[TBD] or globally-scoped behaviour.

Syntax: var variable = value;

Note: It allows it to be re-declared or updated within its scope.

Example:

var num = 5;
console.log(num);

var num = 20; // reassigning is allowed
console.log(num);
Enter fullscreen mode Exit fullscreen mode

2. let Keyword

  • The let keyword is a modern way to declare variables in JavaScript.
  • It was introduced in ECMAScript 6 (ES6)[TBD].
  • Unlike var, let provides block-level scope and cannot be re-declared in the same scope.

Syntax: let variable = value;

Example:

let  age = 22;
age = 29; // Value can be updated
// let age = 15; //can not re-declare
console.log(age)
Enter fullscreen mode Exit fullscreen mode

3. const Keyword

  • It is used to declare variables as constant.
  • That const variables cannot be reassigned.

Syntax: let variable = value;

Example:

const pi = 3.14;
// pi = 3.20; This will throw an error
console.log(pi) 
Enter fullscreen mode Exit fullscreen mode

Overview of Recent Versions

  • ECMAScript 2025 (ES16): The current stable standard approved in June 2025. It introduces native set operations like .intersection(), .union(), and .difference().
  • ECMAScript 2024 (ES15): Released in 2024. It brought data grouping tools like Object.groupBy() and Map.groupBy().
  • ECMAScript 2023 (ES14): Released in 2023. It introduced new array manipulation capabilities like .findLast() and .toReversed().

Note: ECMAScript (ES) is the official, standardized specification for the JavaScript programming language.

What is a Compiler?

  • The Compiler is a translator that takes input i.e., High-Level Language, and produces an output of low-level language i.e. machine or assembly language.
  • The work of a Compiler is to transform the codes written in the programming language into machine code (format of 0s and 1s) so that computers can understand.

https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epk3gkco01rpl9hcci4y.png

What is an Interpreter?

  • An Interpreter is a program that translates a programming language into a comprehensible[TBD] language.
  • The interpreter converts high-level language to an intermediate language[TBD].
  1. It translates only one statement of the program at a time.
  2. Interpreters, more often than not are smaller than compilers.

https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwpkapxi7w6qwgpz3wql.png

References:

https://www.geeksforgeeks.org/javascript/javascript-tutorial/
https://www.w3schools.com/js/js_intro.asp

Top comments (1)

Collapse
 
karthick_k_983555db6df3 profile image
Karthick (k)

Good