【问题标题】:What does .end(data) of a variable mean in node.js?node.js 中变量的 .end(data) 是什么意思?
【发布时间】:2018-02-09 19:44:58
【问题描述】:

我在in this link 播下一个包含以下内容的代码:

var client = clients.pop();
    client.end(//some data here));

其中 Clients 是一个包含一些对象的数组。

变量的 .end(..) 的功能是什么?

谢谢!

【问题讨论】:

  • @DMan 你好,你添加的链接是请求而不是变量
  • clients 是一个请求列表,所以当你弹出一个并将其存储到变量client 中时,client 一个请求,所以你可以拨打.end()就可以了。这有意义吗?
  • @DMan 是的,非常感谢先生

标签: javascript node.js


【解决方案1】:

为了清楚起见,可能值得剖析一下。

// myObject, like client, is an object
var myObject = { data: 123 };

// object slots are referenced by objectName.slotName
// a new slot can be defined "on the fly" using this notation
myObject.flurpies = function () { return 234; };

// myObject.flurpies, like client.end, points to a function

// a function can be called by adding () following the function

// this function call should return 234
myObject.flurpies()

希望对您有所帮助...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-30
    • 2022-01-25
    • 1970-01-01
    • 2020-12-13
    • 2016-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多