trusktr
trusktr

Reputation: 45494

How is it that Meteor.methods is made with "native code"?

When doing console.log(Meteor.methods) in the browser, the result is

function () { [native code] }

I thought [native code] was for functions that are implemented in the browser? Meteor.methods is not built into Chrome, for example. How is this possible?

Upvotes: 2

Views: 62

Answers (1)

imslavko
imslavko

Reputation: 6676

Meteor.methods is a rebind of another JS function: https://github.com/meteor/meteor/blob/devel/packages/ddp/client_convenience.js#L52. There is nothing special about it other than it is a result of Function.bind. Try it in your console:

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

If you print y, it will be [native code] because Chrome doesn't know how to print bound functions best.

Upvotes: 5

Related Questions