---
title: "Discussion on \"Closures, Functions & Event Listener in JavaScript\" | Hashnode"
description: "Discussion on \"Closures, Functions & Event Listener in JavaScript\". Closures\nLet’s see a code snippet first\nfunction x(){\n    var a = 7;\n    function y(){\n        console.log(a);\n    }\n    y();\n}\nx();\n\nWhen we will run this program we know that the output is going to be 7 because when we are trying to access a from t..."
url: "https://hashnode.com/posts/closures-functions-event-listener-in-javascript/678f4cc165dfff997c8eac1e"
---

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

Discussion

# [Closures, Functions & Event Listener in JavaScript](https://techstack-tales.hashnode.dev/closures-functions-event-listener-in-javascript?utm_source=hashnode&utm_medium=feed)

Closures Let’s see a code snippet first function x(){ var a = 7; function y(){ console.log(a); } y(); } x(); When we will run this program we know that the output is going to be 7 because when we are trying to access a from t...

Jan 21, 2025 · 5 min read · techstack-tales.hashnode.dev  
Read the article

-   [#closure](https://hashnode.com/tag/closure)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)
-   [#functions](https://hashnode.com/tag/functions)
-   [#event-listener](https://hashnode.com/tag/event-listener)
-   [#coding](https://hashnode.com/tag/coding)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Harshit Bansal](https://hashnode.com/@TheHarshitBansal)

@TheHarshitBansal · India

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

Developer

Passionate Developer | Lover of coding and problem-solving | Constantly learning and growing | Let's build something amazing!

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
