repl.it
@cmclau01/

Closures

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*function hotLunch() {
  var balance = 25;
  return function(price) {
    balance -= price; //balance = balance - price;
    console.log('You have $' + balance + ' left');
  }
};*/

//memory scope is defined on the right native browser.

// another example:

/*var makeStopWatch = function() {
  var elapsed = 0;
  var stopwatch = function() {
    return elapsed;
  };
  var increase = function() {
    elapsed ++;
  };
  setInterval(increase, 1000);
  return stopwatch;
};
makeStopWatch();*/

function go() {
  var one = 'hi'
}

function firstFn
Native Browser JavaScript
?