I always thought that these callbacks had their own scope. What's going on here?
Eton_file_sync.prototype.add_file_listener = function(filename){
//use chokidar to make a watcher for the filename
var watcher = this.chokidar.watch(filename, {
ignored: /[\/\\]\./,
persistent: true
});
var some_variable = 1;
watcher.on('change', function(path) {
console.log ('File', path, 'has been changed');
console.log (some_variable);
});
};
when calling it by changing the file, why does the output of some_variable actually work?
File buffercont.asc has been changed
1