DEV Community

Alaguselvan T
Alaguselvan T

Posted on

Introduction - JavaScript

History of JavaScript

  • JavaScript is one of the most popular programming languages in the world. It was created to make web pages interactive.
  • JavaScript was created in 1995.
  • It was developed by Brendan Eich.
  • He created the first version in just 10 days

Evolution of the Name
JavaScript went through three names:
Mocha (first internal name)
LiveScript
JavaScript (final name)

What is JavaScript?
-JavaScript (JS) is a high-level, interpreted, object-oriented programming language used to make websites interactive and dynamic.
-Without JavaScript, a website is mostly static.

Example
Imagine a login page:
HTML → Creates the username and password fields.
CSS → Styles the page.
JavaScript → Checks the input, validates it, and displays messages.

What is a Variable?
A variable is a named container used to store data.
Ways to Declare Variables

  1. let (Recommended) Value can be changed. Cannot be redeclared in the same scope.
  2. const (Recommended) Value cannot be reassigned. Must be initialized when declared.
  3. var (Old way) Can be redeclared. Function-scoped. Avoid using it in modern JavaScript.

Data Types
A data type tells JavaScript what kind of value a variable holds.

Primitive Data Types (7)

  1. String Stores text.
  2. Number Stores integers and decimals.
  3. Boolean Stores true or false.
  4. Undefined A variable is declared but not assigned a value.
  5. Null Represents an intentional empty value

Non-Primitive Data Type

1.Object
Objects store data as key-value pairs.
2.typeof
Check a Data Type
Use typeof.

Operators
Operators perform operations on values.

  1. Arithmetic: +, -, , /, %, *
  2. Assignment: =, +=, -=, *=, /=
  3. Comparison: ==, ===, !=, !==, >, <, >=, <=
  4. Logical: &&, ||, !
  5. Increment/Decrement: ++, --

Keywords
Keywords have special meanings and cannot be used as variable names.

Examples:
let
const
var
if
else
for
while
return
function
class
switch

Top comments (0)