Minitech's answer is not bad, but it lacks another scenario. Your declaration function is called a callback, which means two things: first, the function is an object in memory, and the second is the name of the function only to refer to the object. If for any reason you break the link between the two, the proposed code will not work either.
Evidence:
function callback() {
From the Mozilla developer page in description:
Warning. The fifth edition of ECMAScript (ES5) prohibits the use of arguments.callee () in strict mode. Avoid using arguments.callee () either by giving functional expressions to the name, or by using a function declaration in which the function must call itself.
Obviously, this is the first example of a workaround, โgiving the function expressions a name,โ but let's see how we can deal with โor use a function declaration where the function should call itselfโ and what it will bring:
function callback(){
Then we can do whatever we want with a callback link:
var callback2 = callback; callback = null; callback2();
Ivica Jul 09 '15 at 21:25 2015-07-09 21:25
source share