This is my current code:
var PermissionsChecker = {};
PermissionsChecker.check = function(id) {
PermissionsChecker.getPermissions(id);
}
PermissionsChecker.getPermissions = function(id) {
// do stuff
}
Two questions:
- Is this the right way to construct node.js functions?
- Is that line in
.checkthe correct way to refer to a sibling function?
Thanks!
It’s perfectly fine. Some notes:
When a function is called as a method on some object, then the value of
thisinside that function refers to the object on which it was called. That is, callingchecklike this:…allows you to write the function like this:
…which is more succinct and probably more common.
Nothing about your question is specific to node.js. This applies to JavaScript in the browser (or anywhere else), too.
You could save some typing by rewriting your example like this: