Can a function which returns a new object be considered "pure"?

Viewed 316

Given the definition:

A pure function is a function which given the same input, will always return the same output and produces no side effects.

Can we consider function AmIPure as pure function? According to definition no, but I want to make sure.

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
2 Answers
Related