Thank you everyone for all your replies! This is very helpful! I had posted
this question on StackOverflow too so I am going to update StackOverflow
based on the information from this thread. Thank you again!
On Tuesday, January 6, 2015 at 4:19:32 PM UTC-8, Prabhash Rathore wrote:
>
> I recently started programming in JavaScript (Server side) and Node.js. I
> come from Java background where there is a concrete standard on how you
> define Data Object, which is Java Bean. Do we have any such standards in
> JavaScript/Node on how we define Data Objects (similar to Java Beans)?
>
> I have researched at many places and couldn't find any standards. I have
> seen following styles but not sure which is better or recommended:
>
> //bean1.js
> module.exports = function() {var obj = {};
> obj.name = '';
> obj.department = '';
> return obj;
> }
> //bean2.js
> module.exports = function() {
> this.name = '';this.department = '';
> return this;
> }
> //bean3.js
> module.exports = function(param) {var obj = {};
> if(param === undefined) {return obj;}
>
> obj.name = param.name;
> obj.department = param.department;
> return obj;
> }
> //bean4.js
> module.exports = {
> name : '';
> department : '';}
>
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/e7180dbe-13d8-480c-91bf-84afa210a901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.