Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28489 > unrolled thread

create the object with different style in javascript

Started bysharif.ashraful@gmail.com
First post2015-07-30 14:12 -0700
Last post2015-07-30 14:12 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  create the object with different style in javascript sharif.ashraful@gmail.com - 2015-07-30 14:12 -0700

#28489 — create the object with different style in javascript

Fromsharif.ashraful@gmail.com
Date2015-07-30 14:12 -0700
Subjectcreate the object with different style in javascript
Message-ID<bc3ba257-bb7f-4622-b4eb-cafc44ee47f8@googlegroups.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

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web