Here is a piece of code:
if (lastPosition == 0) {
callsomemethod(param);
}
I have this weird situation, wherein I have to call the function callsomemethod(param); even when the if condition is true more than once. In other words, I want to make sure that the function callsomemethod gets called only once even the if statement is true more than once. There are more things happening inside the if statement, I have just taken them out for simplicity.
EDIT:: Thanks for all the responses. Unfortunately, none of the approach is working because the if statement is inside an function and that function is called more than once so everything gets initialized again. Also that function is inside an IIFE. Apologies for not making everything clear in the first shot.
Thanks in advance