Skip to content

Commit 203de4b

Browse files
authored
Update js codes.docx
1 parent 109300f commit 203de4b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

js codes.docx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,16 @@ until they are assigned because they are in Temporal dead zone.To avoid Temporal
18521852
-- callstack
18531853
-- console.log(greetingName) //print the body of a function
18541854

1855+
JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope,
1856+
before execution of the code.
1857+
This is a complete textbook type definition (thanks to MDN Docs for this), but what does it mean in simple words.
1858+
Hoisting simply means that we can access variables, before their initialisation & functions, before their declaration.
1859+
it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope
1860+
regardless of whether their scope is global or local
1861+
1862+
1863+
1864+
18551865
Examples:
18561866
1. Hoisting Function: If i write below code then JS compiler auto move declaration first then call of a function.
18571867
hello() //call

0 commit comments

Comments
 (0)