0

I have JavaScript code and I found the following line :

I'm a bit confused about the syntax:

e = k.attr("data-icon"), e && (a.icon = e), 

I understand the first part k.attr("data-icon") but not the rest.

What does that mean?

7
  • 2
    Do you ask about , or && or both? Commented Sep 14, 2018 at 14:31
  • 2
    see this Commented Sep 14, 2018 at 14:32
  • 1
    stackoverflow.com/questions/3561043/… and stackoverflow.com/questions/41205110/… Commented Sep 14, 2018 at 14:33
  • 1
    The e && (a.icon = e) means -> if e is truthy, set a.icon to the value of e. And e is the value of the previous assignment statement k.attr('data-icon'). This should not have been marked as a duplicate. Commented Sep 14, 2018 at 14:35
  • 3
    This looks very much like minified code, not anything someone has written like that. Do not try to pick up this style. Try finding the un-minified source code instead and learn from there what the code is doing. Commented Sep 14, 2018 at 14:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.