I have following line of code in javascript:
q && (c = q === "0" ? "" : q.trim());
WHat does it mean? I understand that c is equals either empty string or q.trim() result, but what does mean q && ()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JavaScript optimizes boolean expressions. When
qisfalse, the right hand side of the expression doesn’t matter for the result, so it’s not executed at all. So this is a short form of: