Please tell me what this means?

userName = userNodes[i].firstChild ? userNodes[i].firstChild.nodeValue : '';

that is the way that my script that I am modifying makes the username, but I have never seen anything that looks like that before. Can someone explain it in a dumbed down way?

That looks like a JavaScript or JQuery Ternary (Maybe even C)?

sorry forgot to say its jquery, because i need to find a way to get the user’s avatars

It’s setting a variable to one of two values using a ternary operator

condition ? if true : if false

userName = userNodes[i].firstChild ? userNodes[i].firstChild.nodeValue : ''; // set userName to ... // if userNodes[i].firstChild is defined/truthy: userNodes[i].firstChild.nodeValue // else: empty string

Sponsor our Newsletter | Privacy Policy | Terms of Service