Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28489
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2015-07-30 14:12 -0700 |
| Message-ID | <bc3ba257-bb7f-4622-b4eb-cafc44ee47f8@googlegroups.com> (permalink) |
| Subject | create the object with different style in javascript |
| From | sharif.ashraful@gmail.com |
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
Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread
create the object with different style in javascript sharif.ashraful@gmail.com - 2015-07-30 14:12 -0700
csiph-web