I was learning about side effects in JavaScript, and I came across the idea that console.log is considered a side effect. However, I’m not entirely sure why.
For example, in the following function:
function greet(name) {
console.log("Hello, " + name);
return "Hello, " + name;
}
Since console.log does not modify any variables or return values, why is it classified as a side effect?
I tried using console.log inside a function and expected it to just display output without affecting the program’s logic. However, I read that logging is considered a side effect, and I’m trying to understand why