मुझे अभी हाल ही में एहसास हुआ, कि वास्तव में V8/नोड में ऑब्जेक्ट प्रोटोटाइप को बदलना संभव है। हालांकि यह मानक में नहीं है, यह विभिन्न ब्राउज़रों में और विशेष रूप से V8/नोड में संभव है!
function User(username, email) {
this.username = username;
this.email = email;
}
User.prototype.sendMail = function (subject, text) {
mailer.send(this.email, subject, text);
};
var o = {username: 'LoadeFromMongoDB', email: 'example@sqldat.com'};
o.__proto__ = User.prototype;
o.sendMail('Hello, MongoDB User!', 'You where loaded from MongoDB, but inherit from User nevertheless! Congratulations!');
इसका उपयोग विभिन्न मॉड्यूल और प्लगइन्स में किया जाता है - यहां तक कि कोर मॉड्यूल भी इस तकनीक का उपयोग करते हैं, हालांकि यह ईसीएमएस्क्रिप्ट मानक नहीं है। तो मुझे लगता है कि यह नोड.जेएस के भीतर उपयोग करने के लिए सुरक्षित है।