# Shadowing

*noun*

say it: **“SHAD-oh-ing”** **/ˈʃædoʊɪŋ/**

When a variable inside a function or block has the same name as one outside it, so the inner one hides the outer one in that area.

## What is **Shadowing** in JavaScript?

**Shadowing** — When an inner variable has the same name as an outer one, so inside its block or function the name means the inner variable and the outer one can't be reached. It's legal, but it's a common cause of "why didn't my total change?" bugs.

```javascript
let tickets = 10;
function playSkeeBall() {
  let tickets = 3; // a new variable that hides the outer one
  console.log(tickets); // 3
}
playSkeeBall();
console.log(tickets); // 10
```

## In a sentence

- “The price inside the loop is **shadowing** the price at the top of the file, so the loop never sees the outer one.”

Level: Apprentice · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=2)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/shadowing-javascript
