# 什么是纯函数
Issue
欢迎在 Gtihub Issue 中回答此问题: Issue 607 (opens new window)
Author
- 输出仅由输入决定,每一个固定的输入总是返回相同的输出
- 不产生副作用
function push(list, x) {
list.push(x);
return list;
}
const l = [];
push(l, 3);
Author
引用透明
Author
他只使用或者操作输入的参数 相同参数输出相同结果 不能存在语义化的副作用
Author
- 输出仅由输入决定,每一个固定的输入总是返回相同的输出
- 不产生副作用
function push(list, x) { list.push(x); return list; } const l = []; push(l, 3);
这应该是一个错误的例子吧 这个函数改变了 list 本身 纯函数应该是不改变外部数据的