Inclusion
The script tag
External script file
Semicolon
Semicolon
Comment
Comment
Use Strict
Use Strict
Variable and Constant
Variable and Constant
var instead of let
Variable Naming
Case Sensitive
Reserved Words
An Assignment without use strict
Constant
Uppercase Constant
Data Types
Data Types
Number
Infinity
NaN
String
Boolean
Null
Undefined
Type of Operator
Type Conversions
Converting to String
Converting to Number
Converting to Boolean
parseInt() and parseFloat()
Data Types - Part II
Primitive As Object
Constructor method for Primitive type
Numbers
Number.toString
Rounding a Number
Math.floor()
Math.ceil()
Math.round()
Math.trunc()
Math.random()
Math.max(a, b, c, ...)
Math.min(a, b, c...)
Math.pow(n, power)
toFixed()
Infinity and NaN : isFinite and isNaN
Object.is : Strict Equality Check
String
Special Character : Escape Squence
Hexa Code
String length
Accessing characters
charAt()
Strings are immutable
Changing the case
toUpperCase()
toLowerCase()
Searching for a substring
str.indexOf(substr, pos)
include()
startsWith() | endsWith()
Getting a substring
str.slice(start [, end])
str.substring(start [, end])
str.substr(start [, length])
UTF-16 Code
str.codePointAt(pos)
String.fromCodePoint(code)
Operators
String Concatenation
Unary Plus
Assignment
Reminder %
Exponentiation **
Increment/Decrement
Comma
Comparasion Operator
String Comparasion
Array
Declaration
Accessing Elements
Replacing Elements
Trailing Comma
Array can contain any type of Elements
length
array.push(item)
array.pop()
array.shift()
array.unshift(item)
delete
toString
array.splice()
slice()
arr.concat()
Iteration
Array is actually an Object
Performance
new Array()
Iterate: forEach
Searching in array
indexOf()
lastIndexOf()
includes()
find()
findIndex()
filter()
Transform an array
map()
sort()
reverse()
split(delim)
join()
Array.isArray()
Most methods support “thisArg”
Function
Function Declaration
Local Variables
Outer Variables || Global Variables
Parameters
Default Values
Returning Values
Function Expression
Callback Function
Function Declaration Vs. Function Expression
Arrow Function
Object
Object
Literals and properties
Multiword Property
Special property __proto__
Square brackets
Computed Property : Variable as a property
Property value shorthand
Existence check
For In Loop
Copying By Reference
Comparison by reference
Const Object
Cloning Object : Object.assign
Deep Cloning
Methods in an Object
this
Internals: Reference Type
Arrow functions have no “this”
Object to primitive conversion
Symbol.toPrimitive
toString/valueOf
Constructor Function : new
new.target
Global Object : Window
Use of Window
“this” and global object
Symbols
Symbols
Symbols are unique
“Hidden” properties
Symbols in a literal
Symbols are skipped by for…in
Global Symbols
Symbol.keyFor
Get all Symbols : Object.getOwnPropertySymbols()
System Symbols
Iterable
Iterable
Symbol.iterator
String is Iterable
Calling an iterator explicitly
Iterables and Array-Likes
Array.from
Map and Set
Map
map.set(key, value)
map.get(key)
map.has(key)
map.delete(key)
map.clear()
map.size
Map from Object : Object.entries()
Iteration over Map
map.keys()
map.values()
map.entries()
Set
set.add(value)
set.delete(value)
set.has(value)
set.clear()
set.size
Iteration over Set
set.keys()
set.values()
set.entries()
keys(), values() and entries() for Object
Destructing
Destructing Assignment
Array destructuring
Looping with .entries()
The rest ‘…’
Default Values
Object Destructing
Test operator with object
Without let
Nested Destructing
Smart function parameters
JSON
JSON
JSON.stringify()
JSON.stringify fails for Circular Reference
toJSON()
JSON.parse()
Using reviver
Function - II
Recursion
Recursive traversals
Rest parameters
The “arguments” variable
Spread operator
Merging Array using Spread Operator
Spread Operator Works on any Iterator
Array.from Vs Spread Operator
Closure
Lexical Environment
Nested functions
Environments in detail
Lexical Environment for Code blocks and loops, IIFE
Garbage collection of Lexical Environment
Function - III
Function object, NFE
func.name Property
func.length Property
Adding Custom Property
Function Closure Vs Function Property
Named Function Expression(NFE)
Sum with an arbitrary amount of brackets
new Function
Lexical Environment for new Function
Scheduling
Scheduling : setTimeout and setInterval
setTimeout()
clearTimeout()
setInterval()
clearInterval()
Modal windows freeze time in Chrome/Opera/Safari
Recursive setTimeout
Garbage collection : Scheduler
setTimeout(…,0)
Splitting CPU-hungry tasks
Minimal delay of nested timers in-browser
Allowing the browser to render
Decorators, Call, Apply, Bind, Method Borrowing
Transparent caching
func.call()
func.apply()
Borrowing a method
Function binding
Currying
Currying
Advanced curry implementation
Arrow Function
Arrow Function
Arrow functions have no “this”
Arrow functions can’t run with new
Arrows have no “arguments”
Object - II : Property Flags and Descriptors
Property Flags
Read-only
Non-enumerable
Non-configurable
Object.defineProperties
Object.getOwnPropertyDescriptors
Object.getOwnPropertyNames
Object - III : Getters and Setters
Getters and setters
Accessor descriptors
Smart Getters and Setters
Using for compatibility
Object - IV : Prototypal inheritance
[[Prototype]]
Data Properties
Accessor Properties
The value of “this”
F.prototype
Default F.prototype, constructor property
Hiding Properties
Native prototypes
Other built-in prototypes
Native Prototype for Primitive Data Types
Changing native prototypes
Borrowing from prototypes
Methods for prototypes
__proto__ as a key
Getting all properties
Object.getOwnPropertyNames(obj)
Object.getOwnPropertySymbols(obj)
Reflect.ownKeys(obj)
Class
Class
Functional class pattern
Factory class pattern
Prototype-based classes
Prototype-based inheritance for classes
Classes
Constructors require new
Class methods are non-enumerable
Getters/setters
Class Expression
Static methods
Prototype Relation
Class Inheritance
Inheritance
Overriding a method
super
Arrow functions have no super
Overriding constructor
Super: internals, [[HomeObject]]
[[HomeObject]]
Static methods and inheritance
Natives are extendable
Class checking: "instanceof"
isPrototypeOf()
Symbol.toStringTag
Mixins
Mixins
(Incomplete)
Error Handling
Error Handling
Error Object
Example
Throwing Error
Rethrowing
try…catch…finally
Global catch
Custom Error
Custom Error
Extending Error
Further inheritance