I’m not experienced with this but that looks off. The real ngre object is a lot bigger and every time I have to use ngre.checkThis rather than this.checkThis, I feel like I am doing it wrong!
I think either referring to ngre or this is fine, no performance problems there.
checkAnswer may be simpler as a standalone function rather than being attached to that object though, it’s hard to say without seeing the rest of the code but generally I find it easier to separate the data structures from the events.
As I developed I had to move towards the same conclusion, not just for ease of use but found that other objects required the use of same data.
This is off topic, but let me ask you this (as with this project I’m trying to learn best practices)
Here is another module I am working on. All the drag and drop methods are binded. But then I have other methods that are used by the binded methods. Should they be separated?
I read somewhere that each module should serve a purpose. With that logic, am I right in not separating the drag and drop methods from the methods used within the drag and drop methods?
Again it’s hard giving feedback on a snippet of code without context but It does look awkward to me how you’re putting everything into an object, it doesn’t look like it serves a purpose. It’s possible just to have the functions in the scope of that module refer to each other without the wrapping object.
var disable = function() {};
var drop = function(ev) {
disable();
};
module.exports = {
disable,
drop,
};