intro javascript
intro javascript
Variables:
A variable in programming is a container for storing data values. It acts as a symbolic name
(or identifier) that represents a value in a program, allowing you to use and manipulate the
data more efficiently. Variables make your code dynamic and reusable by enabling changes
to stored values.
value
name
Variables Rules:-
1. Variables Names Are Case Sensitive “a” & “A” is different
2. Only Letters, Digits, Underscore(_,-) and $ this are allowed [Not Even A Space]
3. Only a Letter , Underscore(_) or $ should be 1st Character while variable declaration
4. Reserved words cannot be variable name eg: console, function etc
1. Global Scope
Definition:
A variable or function is said to have a global scope if it is declared outside of any
function, block, or module.
Global variables can be accessed and modified anywhere in the program.
2. Block Scope
Definition:
A variable has block scope if it is declared inside a block (enclosed by {}) using let
or const.
The variable is accessible only within that block and its nested blocks.
Example:-
function add(a, b) {
return a + b;
}
let sum = add(5, 3); // Call the function
console.log(sum);
Flow Structure for How the JavaScript manipulates the html tags for website creation.
Windows(browser)
Document Object Model
HTML
head body