DEV Community

PUSHAN VERMA
PUSHAN VERMA

Posted on

1

Execution Context , Hoisting and Access by Value and Access by Referencce

*Execution Context *

//đź“Śexecution context - a environment , where javascript code is executed and evaluated

//global execution context - by default an execution provided by js ,i.e known as global execution context
//this is the place where the whole code resides.

//eg. consider a example of nesting a loop , then the first loop is global exec context and the rest are
// sub exec context

var a =3;
var b =5;

function sum(a,b)
{
return a+b;
}

var sum1 =sum(5,6);
var sum2=sum(a,b);
console.log(sum1);
console.log(sum2);

*Hoisting *

console.log(a);

greet();

var a =2

function greet()
{
console.log("Hello")
}

Access by Value and Access by reference

// đź“ŚPrimitive and Non Primitive data type

//đź“Ś PRIMITIVE DATA TYPE
let a =2.5
console.log(a,typeof(a))

//👉 ans -->2.5 number

let b ="hello"
console.log(b,typeof(b));

//👉ans -->hello string

let c =true
console.log(c,typeof(c));

//👉ans -->true boolean

let d =undefined
console.log(d,typeof(d));

//👉 ans -->undefined undefined

let e =null
console.log(e,typeof(e));

// 👉ans-->null object

//đź“ŚEven though null is a primitive data type , it is given object in js (in js - it is treated as missing object)(it is considered as a bug in js till date)

//đź“Ś NON PRIMITIVE DATA TYPE

let firstperson ="hitesh"

let secondperson =firstperson

console.log(firstperson);
console.log(secondperson);

// 👉ans-->
// hitesh
// hitesh

let firstperson1 ="hitesh"

let secondperson1 =firstperson

firstperson1="arshad"

console.log(firstperson1);
console.log(secondperson1);

//👉 ans -->
// arshad
// hitesh

https://github.com/pushanverma/notes/tree/main/webd

Image of Wix Studio

2025: Your year to build apps that sell

Dive into hands-on resources and actionable strategies designed to help you build and sell apps on the Wix App Market.

Get started

Top comments (0)

đź‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay