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

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -