What Can JavaScript Do?
JavaScript is the programming language of the web.
It can calculate, manipulate and validate data.
It can update and change both HTML and CSS.
JavaScript printing statement:
console.log(50)
output:50
Comments:
Single line comments start with // .
Multi-line comments start with /* and end with */.
JavaScript variables are containers for data.
JavaScript variables can be declared in 4 ways:
Modern JavaScript
Using let
Using const
Older JavaScript
Using var (Not Recommended)
Automatically (Not Recommended)
JavaScript Identifiers:
Variables are identified with unique names called identifiers.
Names can be short like x, y, z.
Names can be descriptive age, sum, carName.
The rules for constructing names (identifiers) are:
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter, a $ sign or an underscore (_).
Names are case sensitive (X is different from x).
Reserved words (JavaScript keywords) cannot be used as names.
JavaScript has 8 Datatypes:
A JavaScript variable can hold 8 types of data:
Type---- Description
String--- A text of characters enclosed in quotes
Number---A number representing a mathematical value
Bigint--- A number representing a large integer
Boolean--- A data type representing true or false
Object--- A collection of key-value pairs of data
Undefined--- A primitive variable with no assigned value
Null--- A primitive value representing object absence
Symbol--- A unique and primitive identifier
The let keyword was introduced in ES6 (2015)
Variables declared with let have Block Scope
Variables declared with let must be Declared before use
Variables declared with let cannot be Redeclared in the same scope
The const keyword was introduced in ES6 (2015)
Variables defined with const cannot be Redeclared
Variables defined with const cannot be Reassigned
Variables defined with const have Block Scope
Top comments (1)
Good