Java Script
Java Script
Why javascript?
Variable Declarations:
1. let
2. const
Difference between let and const is that const declarations should be
initialized and cannot reassign with new value.
Whereas let we can reassign again.
Datatypes:
Operator:
An operator is a special symbol used to perform operations on variables and
values.
1. Assignment Operator
2. Arithmetic operator
3. Comparison operator
4. Logical operator
5. String Operator
6. Other Operator
Type Conversions
1. Implicit conversion also known as type coercion where JavaScript itself
will automatically convert the type.
2. Explicit conversion where you manually convert the type.
Equality
== (Allows coercion)
=== (Does not allow coercion)
Conditional statements
1. If
2. Else
3. Elseif
4. Switch
2
Looping
Loops are used to repeat a block of code
1. While
2. Do...While
3. For
4. For...of loop
Functions
Functions are building blocks of JavaScript
A Js function is a block of code designed to perform a particular task.
Functions are reusable as they can be define once and can be called
with different values resulting in different results.
Functions help to divide a complex problem into smaller chunks and
makes your program easy to understand and maintain.
Scope
Scope determines the accessibility or visibility of variables
1. Block scope
2. Function scope
3. Global scope
3
Advanced JavaScript
Closure
A closure is a combination of a function bundled together with
references to its surrounding state. Closures are created every time a
function is created at function creation time.
Function Currying
4
This Keyword:
The JavaScript this keyword which is used in a function, refers to the
object it belongs to.
It makes functions reusable by letting you decide the object value.
This value is determined entirely by how a function is called.