'node-cron vs setInterval() in setting a database checker job that runs every minute

I was looking on how to implement post scheduling feature in my app, then I discovered node-cron. So theoretically, I can do it using node-cron where the cron job will run every minute and checks the database if a post is due to be posted, and finally post it to the newsfeed.

Then I remembered setInterval(). Javascript setInterval() I think also do the exact same thing with using node-cron. What could be the difference between these two? If setInterval() would also do the job without problems, then I think I should go with it, since it's simpler and native javascript function.

What do you think? I've been searching for answers, but it seems that the opinions for this is 50/50, and there's not much discussion about this matter. Some recommend just using setInterval() if i'm not planning to set a specific date/time. That's right I only wanted to run my job every minute, but then I also read about memory leak in setInterval() which I don't understand fully.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source