Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Lexical Scope

Sumit Rawal answered on May 23, 2023 Popularity 9/10 Helpfulness 2/10

Contents


More Related Answers

  • define lexicographic
  • What is lexical scope in javascript
  • Lexical This
  • Lexical This
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • unexpected lexical declaration
  • Function Scope

  • Lexical Scope

    0

    In this lesson, you will learn about lexical scoping and how it can be used to remove redundancies in your code.

    In our program for computing the square root of a number, we are using the variable x over and over again. We are defining it in each function even though it’s the same variable throughout the program.

    In a previous lesson, we learned that definitions outside a block are visible to definitions inside a block unless they are being shadowed. The process of setting the scope of a variable is known as Lexical scoping and we can use this convention to remove the redundant x variables in our square root program.

    Let’s first take a look at the original program.

    Popularity 9/10 Helpfulness 2/10 Language scala
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 23 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.