This block of code always returns errors:
eval('if(!var_a){return 0;}');
A statement like this works perfectly fine:
eval('alert(1)');
A JavaScript statement such as eval('return 0') always gives an error when its intention is to make the script stop further execution.
eval simply gives unwanted errors when it is run in some block of code and a return statement is in it.
This is because you are using return outside of the context of a function. Wrap your code in a function and return works fine. There are a few ways to do that. I suggest that you do not use any of them. Instead find a way to avoid eval. Regardless, here are some solutions:
eval('(function() { if(!var_a){return 0;} })()');
or
new Function('if(!var_a){return 0;}')()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With