{JS Advanced Topics}

Process

Closures

 

1.

2.

Cache

3.

Memoization

{ScOPE}

Scope manages the accessibility of variables.

Outside of global scope, variable scope is usually defined curly braces 

// insideVar is not available outside of the showScope function
// It's SCOPE is inside that function
const showScope = ( v1, v2 ) => {
 // TODO
 let insideVar = "Inside variable"
}


// v1 and v2 also are not available 
// outsied of the showScope function
// 
const showScope = ( v1, v2 ) => {
 // TODO
 let insideVar = "Inside variable"
 return v1+v2
}


// v1 and v2 also are not available 
// outsied of the showScope function
// 
const showScope = ( v1, v2 ) => {
 // TODO
 let insideVar = "Inside variable"
 return v1+v2
}


// v1 and v2 also are not available 
// outsied of the showScope function
// 
// 
// 3rd slide
const showScope = ( v1, v2 ) => {
 // TODO
 let insideVar = "Inside variable"
 return v1+v2
}

But what if we nest a function inside of another function?



const showScope = () => {

 let insideVar = "Inside variable"
 
 return function innerScope(){
   return insideVar
 }
}


const showScope = () => {

 let insideVar = "Inside variable"
 
 return function innerScope(){
   return insideVar
 }
}

The variable 'insideVar' is accessible by the innerScope function

This is called Lexical Scoping

Lexical scope just means that an inner function has access to variables outside of its scope...

i.e. outside of it's curly braces

Present Syntax Highlighted Code

<section>
  <h2>Tabular Tables</h2>
  <table>
    <thead>
      <tr>
        <th>Item</th>
        <th>Value</th>
        <th>Quantity</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Apples</td>
        <td>$1</td>
        <td>7</td>
      </tr>
      <tr>
        <td>Lemonade</td>
        <td>$2</td>
        <td>18</td>
      </tr>
      <tr>
        <td>Hand Sanitizer</td>
        <td>$999</td>
        <td>2</td>
      </tr>
    </tbody>
  </table>
</section>
# CHAPTER 2

Team & Background

Our design team has a collective 75 years of experience in crafting digital products. Our diverse backgrounds offer a thorough mix of points of view.

Made with Slides.com