gpt4 book ai didi

meteor - Meteor.methods 是如何用 "native code"制作的?

转载 作者:行者123 更新时间:2023-12-02 09:35:31 25 4
gpt4 key购买 nike

在浏览器中执行console.log(Meteor.methods)时,结果为

function () { [native code] }

我认为[native code]适用于在浏览器中实现的功能?例如,Meteor.methods 并未内置于 Chrome 中。这怎么可能?

最佳答案

Meteor.methods 是另一个 JS 函数的重新绑定(bind):https://github.com/meteor/meteor/blob/devel/packages/ddp/client_convenience.js#L52 。除了它是 Function.bind 的结果之外,它没有什么特别的。在控制台中尝试一下:

x = function () {}
y = x.bind(null, 1)

如果打印 y,它将是 [native code],因为 Chrome 不知道如何最好地打印绑定(bind)函数。

关于meteor - Meteor.methods 是如何用 "native code"制作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26696579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com