---
title: "Discussion on \"Understanding Lexical Scope in JavaScript\" | Hashnode"
description: "Discussion on \"Understanding Lexical Scope in JavaScript\". Introduction\nRemember the time when you're writing some code, you try to access an variable but it throws an error that variable is not defined. But you can clearly see that you have defined it and used it multiple times in the function above. That's..."
url: "https://hashnode.com/posts/understanding-lexical-scope-in-javascript/621c6de645bf7fc41cc9f8cb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Understanding Lexical Scope in JavaScript](https://maitrakhatri.hashnode.dev/understanding-lexical-scope-in-javascript?utm_source=hashnode&utm_medium=feed)

Introduction Remember the time when you're writing some code, you try to access an variable but it throws an error that variable is not defined. But you can clearly see that you have defined it and used it multiple times in the function above. That's...

Feb 28, 2022 · 3 min read · maitrakhatri.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Maitra Khatri](https://hashnode.com/@maitrakhatri)

@maitrakhatri · Ahmedabad, Gujarat, India

  
[View profile](https://hashnode.com/@maitrakhatri)

Creator at Brain and Heart

## Responses 1

Markdown supported · ⌘↵ to post

[Prateek Singh](https://hashnode.com/@singh799)

[Jul 12, 2022](https://hashnode.com/posts/understanding-lexical-scope-in-javascript/621c6de645bf7fc41cc9f8cb/comment/62cd07dc0ba13ab923f69de9)

Your article has cleared my thoughts related to lexical scoping.

[Maitra Khatri](https://hashnode.com/@maitrakhatri)

[Jul 12, 2022](https://hashnode.com/posts/understanding-lexical-scope-in-javascript/621c6de645bf7fc41cc9f8cb/comment/62cd07dc0ba13ab923f69de9#reply-62cd30ea8e6c0fc1acab380f)

Glad I could help :)
