You can implement your own recursive protection. There is nothing in jQuery that could help prevent recursion.
function myFunc(arg) {
if (myFunc.in) {
return;
}
myFunc.in = true;
myFunc.in = false;
}
myFunc.in = false;
You can also turn a boolean into a counter and allow recursion only up to a certain number of levels.
FYI, JS , , , - , . , , .
, , :
var myFunc = (function() {
var inCntr = 0;
return function(args) {
if (inCntr !== 0) {
return;
}
++inCntr;
try {
} finally {
--inCntr;
}
}
})();
: try/finally, , ( ).