1
var log = (0, _lodash.memoize)(function (message) {
  console.log((0, _ansicolors.red)('WARNING:'), message);
});

I am facing difficulty in understanding the above code. This code was written in JavaScript.

6
  • Is it the comma operator which you're asking about? Commented Feb 14, 2017 at 7:14
  • my understand is that a function is passed to lodash memoize method as parameter and what that '0' is doing? i may be wrong... Commented Feb 14, 2017 at 7:19
  • 2
    Perhaps this question will show what purpose the 0 might have. Hint: the zero could have been any value. It's the comma which has special behavior. Commented Feb 14, 2017 at 7:23
  • @4castle . Great example. Commented Feb 14, 2017 at 7:25
  • you may have here stackoverflow.com/questions/36076794/… a look too. Commented Feb 14, 2017 at 7:33

1 Answer 1

1

Basically the code (0, _lodash.memoize) eliminates the need to make a new instance and directly gives you the value of function rather than reference.

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.