我正在阅读express 4
的源代码,这是非常新的,并且有以下代码:
var proto = module.exports = function(options) {
var opts = options || {};
function router(req, res, next) {
router.handle(req, res, next);
}
// mixin Router class functions
router.__proto__ = proto;
^^^^^^^^^
router.params = {};
router._params = [];
router.caseSensitive = opts.caseSensitive;
router.mergeParams = opts.mergeParams;
router.strict = opts.strict;
router.stack = [];
return router;
};
我想知道他们使用__proto__
而不是setPrototypeOf
是否有任何理由,除了能够在早于ECMAScript 5.1(ECMA-262)的JS引擎上运行express? / p>