I don't see this often, is this bad practice? [closed]











up vote
-2
down vote

favorite












I usually see the following:
if (true) myFunc();



However my colleague uses: true && myFunc();



Is there anything wrong with the second approach?










share|improve this question













closed as primarily opinion-based by Dekel, Bhojendra Rauniyar, epascarello, Hackerman, Daniel A. White Nov 19 at 15:19


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 2




    Not really. However I find the first one more readable.
    – Kristjan Kica
    Nov 19 at 15:19










  • They do the same thing. Some people like to type less.
    – epascarello
    Nov 19 at 15:19










  • then only always if part going to execute and never goes to the else part
    – mbharanidharan88
    Nov 19 at 15:19










  • No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
    – Bhojendra Rauniyar
    Nov 19 at 15:19






  • 2




    What it returns is not even used so does not even matter
    – epascarello
    Nov 19 at 15:24















up vote
-2
down vote

favorite












I usually see the following:
if (true) myFunc();



However my colleague uses: true && myFunc();



Is there anything wrong with the second approach?










share|improve this question













closed as primarily opinion-based by Dekel, Bhojendra Rauniyar, epascarello, Hackerman, Daniel A. White Nov 19 at 15:19


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 2




    Not really. However I find the first one more readable.
    – Kristjan Kica
    Nov 19 at 15:19










  • They do the same thing. Some people like to type less.
    – epascarello
    Nov 19 at 15:19










  • then only always if part going to execute and never goes to the else part
    – mbharanidharan88
    Nov 19 at 15:19










  • No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
    – Bhojendra Rauniyar
    Nov 19 at 15:19






  • 2




    What it returns is not even used so does not even matter
    – epascarello
    Nov 19 at 15:24













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I usually see the following:
if (true) myFunc();



However my colleague uses: true && myFunc();



Is there anything wrong with the second approach?










share|improve this question













I usually see the following:
if (true) myFunc();



However my colleague uses: true && myFunc();



Is there anything wrong with the second approach?







javascript






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 15:18









Jack Holmes

736




736




closed as primarily opinion-based by Dekel, Bhojendra Rauniyar, epascarello, Hackerman, Daniel A. White Nov 19 at 15:19


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as primarily opinion-based by Dekel, Bhojendra Rauniyar, epascarello, Hackerman, Daniel A. White Nov 19 at 15:19


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    Not really. However I find the first one more readable.
    – Kristjan Kica
    Nov 19 at 15:19










  • They do the same thing. Some people like to type less.
    – epascarello
    Nov 19 at 15:19










  • then only always if part going to execute and never goes to the else part
    – mbharanidharan88
    Nov 19 at 15:19










  • No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
    – Bhojendra Rauniyar
    Nov 19 at 15:19






  • 2




    What it returns is not even used so does not even matter
    – epascarello
    Nov 19 at 15:24














  • 2




    Not really. However I find the first one more readable.
    – Kristjan Kica
    Nov 19 at 15:19










  • They do the same thing. Some people like to type less.
    – epascarello
    Nov 19 at 15:19










  • then only always if part going to execute and never goes to the else part
    – mbharanidharan88
    Nov 19 at 15:19










  • No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
    – Bhojendra Rauniyar
    Nov 19 at 15:19






  • 2




    What it returns is not even used so does not even matter
    – epascarello
    Nov 19 at 15:24








2




2




Not really. However I find the first one more readable.
– Kristjan Kica
Nov 19 at 15:19




Not really. However I find the first one more readable.
– Kristjan Kica
Nov 19 at 15:19












They do the same thing. Some people like to type less.
– epascarello
Nov 19 at 15:19




They do the same thing. Some people like to type less.
– epascarello
Nov 19 at 15:19












then only always if part going to execute and never goes to the else part
– mbharanidharan88
Nov 19 at 15:19




then only always if part going to execute and never goes to the else part
– mbharanidharan88
Nov 19 at 15:19












No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
– Bhojendra Rauniyar
Nov 19 at 15:19




No. It's not bad practice. But it's just a shorthand method where you'll use for short case.
– Bhojendra Rauniyar
Nov 19 at 15:19




2




2




What it returns is not even used so does not even matter
– epascarello
Nov 19 at 15:24




What it returns is not even used so does not even matter
– epascarello
Nov 19 at 15:24

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python