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/85a3bdc4-83af-4c8a-979d-5d527eee8695%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to