repl.it
@cmclau01/

Local arguments in functions

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
31
32
33
34
35
36
37
38
39
40
41
42
43
var blend = function(fruit) {
  console.log(fruit);
}

blend('blueberries');

console.log(fruit);

//also e.g.

var blend = function(fruit) {
  fruit = 'banana';
  console.log(fruit);
}

blend('blueberries');

console.log(fruit);

// parent-child scope:

var outerFunction = function() {
  var x = 10;
  var innerFunc = function( {
    var y = 15;
    console.log(y);
  }
  innerFunc();
  console.log(y);
  }
  outerFunction();
}
// another example:
var g = 'global';

function go() {
  var l = 'local';
  var g = 'in here';
  consol.log(g + ' inside go');
};

go();
console.log(g + 'inside go');
Native Browser JavaScript
?