Short Circuiting With && and || (JavaScript)

Поділитися
Вставка
  • Опубліковано 2 січ 2025

КОМЕНТАРІ • 13

  • @ByteGrad
    @ByteGrad  Рік тому

    Hi, mastering JavaScript is critical if you want to be a modern, professional developer: www.udemy.com/course/professional-javascript-course/?referralCode=0C1D5752923168BC87C2
    Also, if you are a front-end developer then mastering CSS (including Flexbox, CSS Grid, etc.) is equally important: www.udemy.com/course/professional-css/?referralCode=4C3C08E82629E6B15752

  • @pluderr3947
    @pluderr3947 11 місяців тому +2

    Easy and straight to the point.
    Here's my insights I got from the video:
    && --> both conditions must be true in order to run the second part. If one is false, the condition is immediately false and will not even take into consideration, the second part. Both conditions must be true
    || --> if the first condition is true, immediately stop. if the first condition is false, then run the other condition.

  • @HocineKamikaz
    @HocineKamikaz Рік тому +2

    Short and direct thanks mate 🌹

  • @asfandiyar5829
    @asfandiyar5829 Рік тому +1

    Thank you. Just what I needed.

  • @guchierrez
    @guchierrez Рік тому +1

    concise explanation, thanks

  • @vahidseyidov
    @vahidseyidov Рік тому +1

    Great man. Keep it up🙌🏼🙌🏼

  • @jorgeobsv
    @jorgeobsv Рік тому +1

    Great Video! understood 😎😎 ty

  • @TudorTîmplărescu
    @TudorTîmplărescu Рік тому +1

    Thank you! What theme are you using ?

  • @shortsScroll
    @shortsScroll 8 місяців тому +1

    thank you so very much

  • @andromilk2634
    @andromilk2634 11 місяців тому

    I have been testing and here's what I noticed : if you said console.log(9) && 1, you would still receive a log to your console because even though you evaluated the whole expression to "false" (console.log returns undefined), it still ends up logging your input as an indirect operation. So, the actual logging of the input still happens independently of whether it is evaluated as "true" or "false". Finally, it shortcircuits to the first false operand/evaluates its value, and if all operands happen to be true, it always takes the value of the last operand. Is this a correct understanding? Thanks

  • @rt-uh6mt
    @rt-uh6mt Рік тому +1

    So it's just a simplified if statement. Is that the point? Instead of writing an if statement you could just && or ||