---
title: "Discussion on \"Scope Chain & Lexical environment\" | Hashnode"
description: "Discussion on \"Scope Chain & Lexical environment\". In this article, we will see scope, scope chain and lexical environment.\n\nLet us first see a script and try to guess its output\nfunction a(){\nc()\nfunction c(){\nconsole.log(b)\n}\n}\nvar b=5;\na();\n//output:5\nIn the above program, the javascript engine wi..."
url: "https://hashnode.com/posts/scope-chain-and-lexical-environment/60c8512ebbd8c506819af047"
---

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

Discussion

# [Scope Chain & Lexical environment](https://aakankshadhurandhar.hashnode.dev/scope-chain-and-lexical-environment?utm_source=hashnode&utm_medium=feed)

In this article, we will see scope, scope chain and lexical environment. Let us first see a script and try to guess its output function a(){ c() function c(){ console.log(b) } } var b=5; a(); //output:5 In the above program, the javascript engine wi...

Jun 15, 2021 · 3 min read · aakankshadhurandhar.hashnode.dev  
Read the article

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

## Written by

[Aakanksha Dhurandhar👩‍💻](https://hashnode.com/@AakankshaDhurandhar)

@AakankshaDhurandhar · India

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

Love to talk about React,javascript

I am frontend developer from India.

## Responses 2

Markdown supported · ⌘↵ to post

[Saurabh Mhatre](https://hashnode.com/@saurabhmhtr)

[Jun 15, 2021](https://hashnode.com/posts/scope-chain-and-lexical-environment/60c8512ebbd8c506819af047/comment/60c8716ebbd8c506819af370)

Good article with detailed examples and diagrams for explaining concepts. Keep it up 👍

[Aakanksha Dhurandhar👩‍💻](https://hashnode.com/@AakankshaDhurandhar)

[Jun 15, 2021](https://hashnode.com/posts/scope-chain-and-lexical-environment/60c8512ebbd8c506819af047/comment/60c8716ebbd8c506819af370#reply-60c89496590a5c06565662bb)

Thank you

[Yash Tiwari](https://hashnode.com/@Coursesity)

[Jun 15, 2021](https://hashnode.com/posts/scope-chain-and-lexical-environment/60c8512ebbd8c506819af047/comment/60c85316bbd8c506819af0ac)

Great article!

[Aakanksha Dhurandhar👩‍💻](https://hashnode.com/@AakankshaDhurandhar)

[Jun 15, 2021](https://hashnode.com/posts/scope-chain-and-lexical-environment/60c8512ebbd8c506819af047/comment/60c85316bbd8c506819af0ac#reply-60c89487bbd8c506819af660)

Thank you
