---
title: "Discussion on \"How Functions Work in JavaScript and Variable Environment:\" | Hashnode"
description: "Discussion on \"How Functions Work in JavaScript and Variable Environment:\". In this blog post, we will learn about how functions work, what the variable environment is, and how the call stack handles function invocation. We will use an example to understand how this piece of code is executed.\nLet's go through the example:\nin..."
url: "https://hashnode.com/posts/how-functions-work-in-javascript-and-variable-environment/63f7d7f05bcb7c8c399f81b0"
---

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

Discussion

# [How Functions Work in JavaScript and Variable Environment:](https://dailylearn.hashnode.dev/how-functions-work-in-javascript-and-variable-environment?utm_source=hashnode&utm_medium=feed)

In this blog post, we will learn about how functions work, what the variable environment is, and how the call stack handles function invocation. We will use an example to understand how this piece of code is executed. Let's go through the example: in...

Feb 23, 2023 · 6 min read · dailylearn.hashnode.dev  
Updated Mar 7, 2023  
Read the article

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

## Written by

[haresh lakhwani](https://hashnode.com/@Haresh9958)

@Haresh9958 · Ahemdabad India

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

Sr Software Engineer at GlobalLogic.

Experienced developer with a background in native Android development and cross-platform development with React Native. Strong collaborator with a focus on attention to detail and staying up-to-date with the latest technologies. Currently expanding knowledge in data structures and system design. Capable of delivering high-quality applications utilizing React and React Native.

## Responses 3

Markdown supported · ⌘↵ to post

[Lisbeth Purrucker](https://hashnode.com/@lisbethpurrucker)

[Mar 5, 2023](https://hashnode.com/posts/how-functions-work-in-javascript-and-variable-environment/63f7d7f05bcb7c8c399f81b0/comment/6404901a024dffb6cd377c2b)

I think you have to correct your first assignment. In the text you say x = 1, but in your code snippet you assign x = 10.

[Jignesh Kumar](https://hashnode.com/@kumar716)

[Mar 4, 2023](https://hashnode.com/posts/how-functions-work-in-javascript-and-variable-environment/63f7d7f05bcb7c8c399f81b0/comment/6402f3b56cc7b7a22094b640)

Nice explanation !!!

[Samir Jana](https://hashnode.com/@samir94)

[Feb 24, 2023](https://hashnode.com/posts/how-functions-work-in-javascript-and-variable-environment/63f7d7f05bcb7c8c399f81b0/comment/63f888a5207712e9dab06756)

helpful for me, Thanks for writing!
