大家好!谁能解释下http.request 为什么不支持含原型链的对象?
 发布于 9 年前  作者 vince78  3674 次预览  最后一次回复是 9 年前  来自 问答 

举个例子:

var options={protocal:'https:',__proto__: require('url').parse(url)}
var req=new http.ClientRequest(options,cb)
//error :connect ECONNREFUSED 127.0.0.1:80
2 回复
vince78

内部用了 util._extend end!

FoghostCn

楼上说的对,util._extend方法内部实现用了Object.keys方法,看看他的文档:

The Object.keys() method returns an array of a given object's own enumerable properties, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).

这个方法并不会返回对象原型链上的属性,over!