0

I'm trying to get access to this in a function, but it's undefined.

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

}

...

_.each(config, processEachPath);
2

1 Answer 1

1

You need to explicitly bind it to the function:

function processEachPath(element, index, list) {
    logger.debug(_this);
}

// ...

(processEachPath.bind(this))();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.