You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: js codes.docx
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1852,6 +1852,16 @@ until they are assigned because they are in Temporal dead zone.To avoid Temporal
1852
1852
-- callstack
1853
1853
-- console.log(greetingName) //print the body of a function
1854
1854
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
+
1855
1865
Examples:
1856
1866
1. Hoisting Function: If i write below code then JS compiler auto move declaration first then call of a function.
0 commit comments