Sorry for the really weird title, but here’s what I’m trying to do: Show
As you can see, I would like to access the current function from within an anonymous function. Is this possible?
gustavohenke 40k13 gold badges117 silver badges123 bronze badges asked Jan 11, 2011 at 5:07
Nathan OsmanNathan Osman 68.8k70 gold badges250 silver badges350 bronze badges Name it.
answered Aug 3, 2015 at 20:46
6 Yes – NOTE: This is deprecated in ECMAScript 5, and may cause a performance hit for tail-call recursion and the like. However, it does work in most major browsers. In your case,
Rory O'Kane 27.7k11 gold badges92 silver badges128 bronze badges answered Jan 11, 2011 at 5:10
Christian MannChristian Mann 7,7605 gold badges39 silver badges51 bronze badges 7 You can access it with
answered Jan 11, 2011 at 5:13
David TangDavid Tang 90.4k29 gold badges165 silver badges149 bronze badges 5 answered Aug 8 at 13:25
Not the answer you're looking for? Browse other questions tagged javascript function or ask your own question.View Discussion Improve Article Save Article View Discussion Improve Article Save Article Given a function and the task is to get the name of function that is currently running using JavaScript.
How do you call a function within a function in JavaScript?Nested functions in JavaScript.. Write one function inside another function.. Make a call to the inner function in the return statement of the outer function.. Call it fun(a)(b) where a is parameter to outer and b is to the inner function.. Finally return the combined output from the nested function.. How do you check if a function is executed in JavaScript?how to check if function(s) have been executed?. You can drop the == true since they both return booleans. ... . If this condition if (function1() && function2() ){ is true, it means that these functions was executed and returned true.. How do you pass a function in JavaScript?If you want to pass a function, just reference it by name without the parentheses:. function foo(x) { alert(x); } function bar(func) { func("Hello World!" ... . function foo(x) { alert(x); } function bar(func) { func(); } //alerts "Hello World!" (. How do you determine whether a function exists by using the type of operator?Alternatively, we can use the typeof operator. This operator will check whether the name of the declared function exists and whether it is a function and not some other type of object or primitive. In the example above, we test if nameOfFunction exists, and if it does we run it.
|