Skip to content
Advertisement

How I can reset variable value when function end?

I have such function and global variable (as array):

JavaScript

Every call of this function push some data to array. In this function I use recursion. So how i can clear this array only when this function will end it’s work.

Advertisement

Answer

You can call the recursion function inside another function this way you can run anything you want when the function ends

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement