Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="state retained in outer function scope">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// Code in the global scope has access to variable `g`
// but not `o` nor `i`.
var g = 'global';
function outer () {
  // Code in this function scope has access to variables
  // `o` and `g`
  // but not `i`.
  var o = 'outer';
  
  function inner () {
    // Code in this function scope has access to variables
    // `i`, `o` and `g`.
    var i = 'inner';
  }
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
jciolekpro
0viewers