ECMA Script is a standard on which JavaScript is based
Definition
Type Coercion => When you try to add string and number then JS will convert the number into a string and then add it
Pure JS = Vanilla JS
ECMA Script => Standards & Updates of JS
Framework > Package > Library > Module
Destructuring => Destructuring is breaking down a complex structure into simpler parts
AJAX => Asynchronous JavaScript And XML
No page Reload/Refresh
Saves network bandwidth
Uses XMLHttpRequest (xhr) object
Modern websites uses JSON
Data can be transferred in any format => .html, .txt, .http, .https, .json
Case types
camelCase
kebab-case
snake_case
PascalCase
JSON => JS Object Notation
Single quote not supported
Asynchronous Programming => Actions that we initiate now and they finish later
Callbacks
Promises
Fetch API
Async/Await
Uses
In-Browser JS
JavaScript can add new HTML and change existing HTML from DOM (web page)
It can even react to any events (actions)
It can also manage the AJAX requests (GET or POST request)
JavaScript can get and set cookies and use local storage
JavaScript cannot read or write to and from a computer hard disk without user permissions
The browser does not allow the JavaScript of any website to collect the AJAX information of the other website because it generates the error of the same-origin policy
JavaScript can only access the permitted resources but cannot access your documents on personal computers
Server-Side
Iterator => Object that knows how to access items from a collection one at a time, while keeping track of its current position within that sequence
Hoisting
JS appears to move every function with the function keyword at the top of the file
Also hoists var at the top but not initialized
Function/Class expressions are not hoisted
Closure
Combination if a function bundled together with references to its surrounding state (lexical environment)
Generator
Data Types
Primitive
null
typeof returns value as an object
let variable = null
number
let variable = value
string
let variable = "value"
Type conversion into number gives NaN (Not a Number)
symbol
The main purpose of symbols was to provide globally unique values that were kept private and for internal use only, Symbols are ignored in for in loop & JSON.stringify
let variable = Symbol("value")
boolean
let variable = true
Type conversion into number gives 1/0
bigint
let variable = BigInt("value")
undefined
Default value
let variable = undefined
Reference
arrays
objects
functions
dates
Variables
Basic
(typeof var) => Returns dataType of the given variable
Dynamic typed language
Type of a variable can be change in run-time
Type Conversion
var = String()
var = Number()
var1 = Number.parseInt(var) => Converts into Integer
var = parseFloat()
Type
var
Can be Re-declared and Updated
Initial value of declared variable is undefined
Global scope
var variable = value
let
Can be Updated but not Re-declared
Initial value of declared variable is not undefined
Block level scope
let variable = value
const
Can not be Updated or Re-declared
Block level scope
Must be initialized during declaration
Values inside a const Object can be changed
const variable = value
Scope
Local
Function
Global
Expression
Operators
Arithmetic Operator
Unary
++N, --N, N++, N--
Binary
+, -, *, /, %, **
Comparison Operator
Returns Boolean value
Types
==, !=, ===. !==, >, <, >=, <=, ?
Logical Operator
Used to connect multiple expressions or conditions together