Last active
July 4, 2017 09:08
-
-
Save DrAzraelTod/4a0debcff210717f3a58f1cc491a4d1d to your computer and use it in GitHub Desktop.
Kleiner JS-Spaß mit arguments.callee.name
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
x = function(foo) { console.log(arguments.callee.name) }; | |
x("test") | |
> x | |
y = function(func) { func("bar") } | |
y(x) | |
> x | |
z = x | |
z() | |
> x | |
x = undefined | |
z() | |
> x | |
y(function() {console.log(arguments.callee.name)}) | |
> undefined | |
var y = function() {console.log(arguments.callee.name)} | |
y() | |
> y | |
a = y | |
delete(y) | |
y() | |
> Uncaught ReferenceError: y is not defined | |
a() | |
> y | |
b = function(foo) { | |
console.log( | |
arguments[0]() | |
) | |
}; | |
b(function() { return arguments.callee.name }) | |
> "" | |
var x = function(foo) { | |
if(foo === undefined) { | |
return eval(arguments.callee.name+"('bar');"); | |
} else { | |
return foo; | |
} | |
}; | |
x() | |
> "bar" | |
z = x; | |
z(); | |
> "bar" | |
delete(x); | |
z() | |
> Uncaught ReferenceError: x is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment