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

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay