Best Practices - Should I pass args to function/method if they live higher up in scope?
If I have variables that are part of the parent/global scope, is it necessary to pass them into a helper function if they can just be referenced within that function?
E.g. - let's say I'm working on a list of items with pagination
``` const allItems = [<array of 50 items>]; const limit = 10; let currPage = 1; let currItems;
// this? currItems = getItemsForPage(itemList, currPage, limit); // or this? currItems = getItemsForPage();
// this? function getItemsForPage(data, pageNo, num) { // calculate and return using data, pageNo, num }
// or this? function getItemsForPage() { // calculate and return using allItems, currPage, limit } ``` Seems like the first is more re-usable, but not sure if either is considered 'better'