1
你好,我目前使用的网站“Codeschool.com”,我觉得教官代码中有一个无限循环中的节点/ Javascript代码,但我不能肯定。这个While循环如何结束? - 节点编号
下面是代码:
http.createServer(function(request, response) {
response.writeHead(200);
request.on('readable', function() {
var chunk = null;
while(null !==(chunk = request.read())) {
response.write(chunk);
}
});
request.on('end', function() {
response.end();
});
}).listen(8080)
教员说,这个代码是类似于使用request.pipe(响应);
我理解这个概念,但什么扔我一个循环(没有双关语意)是这个while循环,它是如何了得?
当'request.read()' null'分配''到chunk',条件不满足,它停止,因为它是现在'=== null'。 – 2017-04-06 00:11:40