Is it possible to call function which calls pure function can be called pure function? How I understand 'pure function' is the function that always give same output on same input. Then let's do image this case.
const function1 = name => {
console.log(`${name}`);
};
const function2 = name => {
function1(name);
console.log('you')
}
I know it's possible to look bit stupid, but what confused me is the example what I've seen as example of pure function. Because usually example was like this.
var c = 10;
function add2(a,b){
return a + b + c;
}
console.log(add2(10,3)); // same
console.log(add2(10,3)); // same
c = 20;
console.log(add2(10,3)); // different
Then like we changed c on last code, if we change function1 on the first example, then function2 will be different as well. This simple thing make me curious how can I define 'pure function' strictly.
- edited)
const function1 = name => {
return `hi, ${name}`;
};
const function2 = name => {
return `${function1('Alice')} and ${name}`};
}