给出定义:
纯函数是给定相同输入的函数,将始终返回相同的输出并且不产生副作用。
我们可以将函数视为AmIPure纯函数吗?根据定义没有,但我想确定一下。
function Amount(value, currency) {
this.value = value;
this.currency = currency;
}
function AmIPure(value, currency) {
return new Amount(value, currency);
}
var foo = AmIPure(5, "SEK");
var baz = AmIPure(5, "SEK");
console.log(foo === baz); //false
Run Code Online (Sandbox Code Playgroud)