Mongoose does not augment the global prototype. The behavior you are seeing is not unique to mongoose. In JavaScript, manipulating Object.prototype impacts _all_ objects. Unless you make the addition non-enumerable you'll see bugs popping up anywhere a `for in` loop is used to iterate an object.
In general mongoose should not be iterating objects using `for in` but in some cases we must do so to guarantee index key ordering and a few others.
In general, its safer practice to write your libs not to augment global prototypes and instead create subclasses or class wrappers etc that you pass your specific objects into. For example, instead of adding `isArray`, `toInteger` to Object.prototype, create a helper module that you pass the arguments into:
// object-helpers.js
exports.isArray = function (obj) {
return Array.isArray(obj);
}
exports.toInteger = function (obj) {
// test for a number and convert obj etc
}
Then include your helper module in your project:
// project.js
var helper = require('./object-helpers.js');
helper.isArray([]) // true
helper.isArray({}) // false
For general purpose helpers search
npmjs.org for something like underscore or lodash to get some more ideas.