大家好!谁能解释下http.request 为什么不支持含原型链的对象?
举个例子:
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 回复
楼上说的对,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!