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
- let (Recommended) Value can be changed. Cannot be redeclared in the same scope.
- const (Recommended) Value cannot be reassigned. Must be initialized when declared.
- 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)
- String Stores text.
- Number Stores integers and decimals.
- Boolean Stores true or false.
- Undefined A variable is declared but not assigned a value.
- 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.
- Arithmetic: +, -, , /, %, *
- Assignment: =, +=, -=, *=, /=
- Comparison: ==, ===, !=, !==, >, <, >=, <=
- Logical: &&, ||, !
- 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)