Which strategy would be better?
// Creating the constant OUTSIDE the loop. const expected = "Some String"; let expectedFound = result.some((element) => { return element.textContent === expected; }); // Creating the constant WITHIN the loop. let expectedFound = result.some((element) => { const expected = "Some String"; return element.textContent === expected; }); Usually one says that one should declare variables as close to their actual usage as possible. But I'm not sure concerning the shown situation.
Wouldn't it be better to create the constant only one-time? Can't it cause (theoretically) a problem a create lots of variables when the array is very large?