#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Fundamentals

Variables in JavaScript: Declaration, Types, Scope

Declaring Variables: var, let, const

  • var — function-scoped, can be redeclared and updated, hoisted with undefined.
  • let — block-scoped, can be updated but not redeclared in the same scope.
  • const — block-scoped, cannot be updated or redeclared; must be initialized at declaration.
var x = 10;
let y = 20;
const z = 30;

Scope of Variables

  • Global scope — declared outside any function, accessible everywhere.
  • Function scope — declared with var inside a function, accessible only within it.
  • Block scope — declared with let/const inside { }, accessible only within that block.

Ready to master real-world JavaScript development?

Learn JavaScript hands-on with mentor-led, live sessions.

Explore Course