---
title: "What are the scopes of a variable in JavaScript ?"  
description: "What are the scopes of a variable in JavaScript ?"  
author: "Anonymous User"  
published: 2019-04-05  
updated: 2020-09-21  
canonical: https://www.mindstick.com/interview/23491/what-are-the-scopes-of-a-variable-in-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# What are the scopes of a variable in JavaScript ?

That is the scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.

**Global Variables in Javascript** − The global variable has a global scope which means this is visible everywhere in your JavaScript code.

**Local Variables in Javascript** − The local variable will be visible only within a function where it is defined. The function parameters are always local to that function.

## Answers

### Answer by Anonymous User

That is the scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.

**Global Variables in Javascript** − The global variable has a global scope which means this is visible everywhere in your JavaScript code.

**Local Variables in Javascript** − The local variable will be visible only within a function where it is defined. The function parameters are always local to that function.


---

Original Source: https://www.mindstick.com/interview/23491/what-are-the-scopes-of-a-variable-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
