Last active
January 12, 2016 21:54
-
-
Save quidmonkey/7b0f20aa74614aa68df8 to your computer and use it in GitHub Desktop.
JavaScript Anonymous Function Call Stack Test in ES5 & ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// anonymous function call stack test | |
// tested and works in chrome, ff, safari, node 4.2.2 | |
// does not work in ie9 or ie11 | |
var f = function f() { g(); }; | |
var g = function g() { h(); }; | |
var h = function h() { console.log(x) }; | |
try { | |
f(); | |
} catch (e) { | |
console.error(e); | |
} | |
var obj = { | |
x: 'foo', | |
y: function () { | |
console.log(x); | |
} | |
} | |
obj.y(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// anonymous function call stack test | |
// tested and works in chrome, ff, node 4.2.2 | |
const f = () => g(); | |
const g = () => h(); | |
const h = () => console.log(x); | |
try { | |
f(); | |
} catch (e) { | |
console.error(e); | |
} | |
const obj = { | |
x: 'foo', | |
y() { | |
console.log(x); | |
} | |
}; | |
obj.y(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script src="anonymous-es5.js"></script> | |
<script src="anonymous-es6.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment