0% found this document useful (0 votes)
18 views16 pages

Fundamentals of Javascript 1700455336

Uploaded by

Andre Carvalho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views16 pages

Fundamentals of Javascript 1700455336

Uploaded by

Andre Carvalho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Javascript_Capsules

Critical Fundamentals
01

Introduction
In this tutorial we will explore some Critical Javascript
Fundaments with examples

Table of contents
Execution Context
Hoisting
Function declaration VS Function expression
Lexial Environment

Scope & Scope Chain


Type Coercion
Passing By Value & Reference
Cloning Objects

Javascript_Capsules
02

Execution context
Is the environment where code executes.

Phases of Execution Context :


.
Creation Phase

Execution phase

Javascript_Capsules
03

Creation Phase

1. Create a global object


2. create this and binds global object to it
3. set up the heap and store variables and fn declaration

Javascript_Capsules
04

Execution Phase
1-executes code line by line
2-assign values to variables
3-invoke functions

Example >>> Guess what would be answer to that ?

Javascript_Capsules
05

Execution Phase example (answer)

First variables and fn declarations are stored in heap


Then at execution phase following line by line:
Var num is already there but never assigned at the
first console.log not until last line of code

Guess what would happen if we changed var by let or const?

Javascript_Capsules
06

Hoisting
Is to assign values before intialize or invoke fn before
declaration

Javascript_Capsules
07

Fn_declaration VS Fn_expression
Function declaration : is usual function
Function expression : is to assign fn to variable

Javascript_Capsules
08

Fn_declaration VS Fn_expression
Try to answer this code by applying what you understood

Javascript_Capsules
09

Lexical Environment
A specification according to ECMAScript all variables and
function declarations are important think it like a
container

Javascript_Capsules
10

Scope & Scope Chain


Scope : is visibility of variables
or functions to executing code .

In JavaScript a variable or
function is visible to executing
code if it is in the current lexical
or the parent lexical
environment

Nested functions creates the


Scope Chain

Javascript_Capsules
11

Block Scope
Represnts any thing within curly braces { } when using let and
cosnt

Javascript_Capsules
12

Type Coercion
is process of converting JavaScript type to another

Types of coercion:
Explicit
Implicit

1-Boolean( )
2-String( )
3-Number( )

Javascript_Capsules
13

Passing By Value & Reference

JavaScript Primitives are passed by


value while the Object and array are
passed by reference

Javascript_Capsules
14

Cloning Objects
Three Methods to clone an
object:

1- Object.assign( )
2- {... object}
3- JSON

Javascript_Capsules
15

Quick notes:
JavaScript is a dynamiclly type language as we can
assign different datatypes to same variables

A function is a special type of object but is still an object

Falsy Values are : 1- false 2- null 3- undefined 4- 0


5- NAN 6- empty String

Loose equality “==” : checks if it has same value

Strict equality “===” : checks if has same value and type

BigInt : is a data type by adding (n) to a number or by


using construcor BigInt()

Javascript_Capsules

You might also like