let previousResult =0;functionaddMoreNumbers(num1, num2) {constsum= num1 + num2; previousResult = sum; // Here we have the side effectreturn sum;}console.log(addMoreNumbers(1,2));
Another example can be:
consthobbies= ['Sports','Cooking'];functionprintHobbies(h) {h.push('NEW HOBBY'); // Side effect hereconsole.log(h);}printHobbies(hobbies);