Skip to content

Instantly share code, notes, and snippets.

@egoing
Last active September 6, 2022 07:53
Show Gist options
  • Save egoing/7e8bce3f04542e061629166be91598cc to your computer and use it in GitHub Desktop.
Save egoing/7e8bce3f04542e061629166be91598cc to your computer and use it in GitHub Desktop.
execute context example
<script>
n0='n0';
var v0='v0';
let l0='l0';
const c0 = 'c0';
console.log(v0, n0, l0, c0);
console.log(window.v0, window.n0, window.l0, window.c0);
function fn2(){
n2='n2';
console.log(n0, n1, n2);
var v2='v2';
console.log(v0, v2);
// console.log(v1)
let l2='l2';
console.log(l0, l2);
// console.log(l1);
const c2='c2;';
console.log(c0, c2);
// console.log(c1);
}
function fn1(){
n1='n1';
var v1='v1';
let l1='l1';
const c1='c1';
fn2();
}
fn1();
console.log(n2);
// console.log(v2, l2, c2);
</script>
<script>
n0='n0';
var v0='v0';
let l0='l0';
const c0 = 'c0';
console.log(v0, n0, l0, c0);
console.log(window.v0, window.n0, window.l0, window.c0);
function fn1(){
n1='n1';
var v1='v1';
let l1='l1';
const c1='c1';
function fn2(){
n2='n2';
console.log(n0, n1, n2);
var v2='v2';
console.log(v0, v2);
console.log(v1)
let l2='l2';
console.log(l0, l2);
console.log(l1);
const c2='c2;';
console.log(c0, c2);
console.log(c1);
}
fn2();
}
fn1();
console.log(n2);
// console.log(v2, l2, c2);
</script>
<script>
n0='n0';
var v0='v0';
let l0='l0';
const c0 = 'c0';
{
n1='n1';
var v1='v1';
let l1='l1';
const c1='c1';
{
n2='n2';
var v2='v2';
let l2='l2';
const c2='c2;';
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment