FP-1
function add(a, b) {
return a + b;
}Not Pure Function
1. 참조하는 변수가 상수가 아닌 변화하는 값
var c = 20;
function add3(a, b) {
c = b;
return a + b;
}
console.log(add3(10,1));
console.log(add3(10,2));
console.log(add3(10,3));
c = 40;
console.log(add3(10,1));
console.log(add3(10,2));
console.log(add3(10,3));2. 객체의 프로퍼티를 직접 변경
평가 시점이 중요하지 않다.
정리
Last updated
Was this helpful?