MCPcopy Create free account
hub / github.com/appacademy/Module-1-Resources / myFunc

Function myFunc

w2/d4/scratch.js:5–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3// let name = "global scope";
4
5function myFunc() {
6 // function/local scope
7 // let name = "function/local scope";
8
9 if (true) {
10 // block scope
11 // let name = "block scope 1";
12
13 for (let i = 0; i < 1; i++) {
14 // another block scope
15 let name = "block scope 2";
16 // console.log(name); // block scope 2
17 // * if were not able to find the variable we need in the immediate scope, js will scope chain to the outer scopes to find one, in this case, if js did not find name in block scope 2, js will scope chain up and find the name in block scope 1
18 // * we can go inward -> outward
19 // ! not outward -> inward
20 }
21 }
22
23 // global declared variable
24 // ! don't do this
25 brandonPassword = "bad";
26}
27
28// myFunc();
29

Callers 1

scratch.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected