I want to know if these two scripts do the same thing:
parseInt(num)?num=parseInt(num):num=str.length
and
num=parseInt(num)||str.length;
And in case they are not, I need to know what the second do.
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.
Yes they are same with later (short circuit evaluation) being terse and a beauty of JS (or other languages that support it):
Both in turn are short-cut of this:
Good Practices:
varkeyword beforenumvariable otherwise it goes into global scope.parseIntegparseInt(num, 10)unless otherwise neededReadings: