KandZ – Tuts

We like to help…!

Javascript 5 🧬 variable hoisting and var vs let

a - variable hoisting
Hoisting is a JavaScript behavior where variables and function declarations are moved to the top of their containing scope
This means you can use variables or functions before they are declared.
This happens when you use var for the declaration
using let and const it gives different result. It results in a Reference Error.
Summary: var → hoisting happens, variable is initialized with undefined
let and const → variables are in a temporal dead zone until declared
function declarations → entire function hoisted to the top of its scope

b - var vs let
var declared variables are function scoped.
let declared variables are block scoped
for var declared variables hoisting happens, variable is initialized with undefined
for let declared variables are in a temporal dead zone until declared
var declared variables can be re-declared within the same scope
let declared variables cannot be re-declared within the same scope
var re-declaration example → No error, re-declaration is allowed
let re-declaration example → SyntaxError: Identifier 'e' has already been declared

Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock