The reason is that in both the Lo-Dash example and in custom constant
implementation, the function created always returns a reference to the same instance. That is to say, in both these snippets only one object is ever created:
var cnst = _.constant({test: 'It Works!'})
var constant = function(value){return function(){return value}}
var t = constant({test: 'Closured Works!'})
This can be confirmed by checking:
console.log(newCnst === cnst()) // true
console.log(t2 === t()) // true
However, in this example:
var test = function(){return {test: 'It Works!'}}
A new object is created every time the function is called. So when you call:
var newTest = _.assign(test() /* new object created here */, {test: "It doesn't work!"})
console.log(test() /* new object created here */)
console.log(newTest)
This can be confirmed by checking:
console.log(newTest === test()) // false