Expressions vs statements in JavaScript, know the difference

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024
  • Understanding the difference between expressions and statements, and knowing how to convert statements into expressions is really important for success in frameworks built on top of of JavaScript that use JSX.
    ℹ️ This video is part of a crash course series, JS Essentials for WP Devs. Get the entire series, the code repository, and more by signing up for the series via email: aurooba.com/js...
    If you found this video helpful, please subscribe and hit the like button!

ความคิดเห็น • 15

  • @MarkRootWiley
    @MarkRootWiley 7 หลายเดือนก่อน

    I knew ternaries, but this explanation of _why_ you need to use them in JSX is really clarifying! They are expressions! Thanks, Aurooba!

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน +1

      My pleasure! It's one of those questions that just bugs you in the back of your mind right?

  • @nazim848
    @nazim848 7 หลายเดือนก่อน

    Great explanation, Aurooba. Excited for more videos!

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน +1

      Thanks Nazim! Let me know if you have any questions as more videos come out. Happy to answer things and clarify as we go!

  • @kellenmace
    @kellenmace 7 หลายเดือนก่อน

    Great lesson & explanation! 👏🏼

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน

      Glad you liked it!

  • @programmingholic
    @programmingholic 7 หลายเดือนก่อน

    keep it up Aurooba, Thanks for sharing. which theme you are using ?

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน +1

      Glad you enjoyed the first lesson in the series! Do you mean my VS Code theme? I used Dracula Pro. 😊

  • @dsebao
    @dsebao 7 หลายเดือนก่อน

    Great content!

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน

      Glad you enjoyed it! Looking forward to your feedback on the rest as it comes out!

  • @kellenmace
    @kellenmace 7 หลายเดือนก่อน

    In my opinion, this is one of the really nice things about Svelte’s template syntax over JSX: statements are allowed 😍

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน

      I think in a well architected React component, you won't see too many expressions. In my opinion what makes the return area of a JSX component highly readable and usable is when the logic has been abstracted away BEFORE the return statement, leaving you with very few expressions and just other React elements. So from that perspective, I don't really mind. But I totally get what you mean.

  • @wpmarkuk
    @wpmarkuk 7 หลายเดือนก่อน

    🤔 I get an expression, I think, but not a statement. Is a statement an expression plus something else? Does it have to contain an expression?

    • @AuroobaMakes
      @AuroobaMakes  7 หลายเดือนก่อน +1

      Ah. The video focusses more on expressions because it's the expressions you need to definitely understand. However, this is a really good question Mark! A statement is one complete instruction in programming. There are simple statements and compound statements that have other statements nested inside them.
      There are two main kinds of statements: declaration statements that set or assign something (like say a statement that assigns a value to the variable 'label') and control statements (sometimes called control flow statememts) which dictate the order of how other statements should be conducted (think an if statement or a while loop or a for loop).
      So if I were to put it in more plain english language, a statement is a complete instruction with a subject and a verb. For example a "return statement", there the verb is "return" and the subject is whatever we are returning.
      Does that help clarify things a bit more?

    • @wpmarkuk
      @wpmarkuk 7 หลายเดือนก่อน

      Yes that is clearer now - thanks