javascript - Using "this" in a function in Node.js -


i'm trying access this in function, it's undefined.

function processeachpath(element, index, list) {     logger.debug(this);  } 

...

_.each(config, processeachpath); 

you need explicitly bind function:

function processeachpath(element, index, list) {     logger.debug(_this); }  // ...  (processeachpath.bind(this))(); 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -