I don't really see the need for the extend at all. In fact if you don't use it, it will work the same as example 1 and you'll still have access to self.
Or you can just do this.foo = foo; this.value = value; at the end instead of returning an Object.