Or why. None of the examples seem like constructors provide any advantage over literals.
function getObject(val1, val2) { return { foo: val1, bar: function() { return val2; } }; }
Or why. None of the examples seem like constructors provide any advantage over literals.