sharif.ashraful
7/30/2015 9:13:00 PM
is it possible to create object the following two style with same name
var user = Client.User // Client->User will be create default construct
var user = Client.User(2) // Client->User will be create with id ( pass id to construct )
i am trying to the following way..
<code>
Object.defineProperty(Client, "User", {
get: function get( ) {
fn = function UserModel( id ) {
return new User( id )
}
return fn;
},
enumerable: true
});
</code>
it's work
Client.User(2)
-------
but it does not work, it's return UserModel function instead of User object
Client.User
is there any way to create object like that style with same name ?
Thanks