Skip to content

Instantly share code, notes, and snippets.

@robcolburn
Created May 14, 2012 16:45
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 robcolburn/2695003 to your computer and use it in GitHub Desktop.
Save robcolburn/2695003 to your computer and use it in GitHub Desktop.
<a href="javascript:foo()">foo</a>
<script>
function foo() {
function allDone () {
return 'sweet, declaration at the beginning.'
}
'set a break here';
'check out the scope variables';
return allDone();
'...';
try {
var a = 'please not here';
} catch (e) {
var b = 'really?'
} finally {
var c = ':-P'
}
var a = 1, b = 2, c = 3, d = 4;
function iLikeHoist () {
}
iLikeHoist.prototype.fun = function () {
return (
'Assignment on a hosted function.' +
'Pop quiz. Is it applied?' +
'You just lost time debugging' +
'Your welcome'
);
}
function iLoveHoist() {
return 'not done yet...'
}
try {
var spitefulVar1 = a;
function spitefulHoist (){
return 'now wat?' + spitefulVar1;
}
function allDone () {
return spitefulHoist();
}
} catch (e) {
function moreSpite () {
return 'haha';
}
function allDone () {
return moreSpite();
}
} finally {
function spitefulHoist () {
return 'i do declare'
}
function allDone () {
return spitefulHoist();
}
}
return 'impossible for code to reach here, right?';
function spitefulHoist () {
var a = [
'an array of strings? well just part of the stack frame' +
'so, it will just be ref-counted and dealloced' +
'wrong, arrays need to be alloced in the heap' +
'will trigger a GC to run'
];
a.push('will practically force a GC run now');
return 'the end';
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment