Skip to content

Instantly share code, notes, and snippets.

@nicholasbs
Created August 20, 2012 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasbs/3406421 to your computer and use it in GitHub Desktop.
Save nicholasbs/3406421 to your computer and use it in GitHub Desktop.
Example 1 (Chrome profiler)
<html>
<head>
<script>
function makeClosure () {
var str = "This string was closed over";
return function () {
console.log(str);
};
};
var myClosure = makeClosure();
myClosure(); // prints "This string was closed over"
</script>
</head>
<title>Example #1</title>
<body>
<h1>Example #1</h1>
<p>
Open up the Chrome profiler and follow the steps in the post.
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment