Conditional statement

edited June 2016 in JavaScript

I am learning about the conditional statement in my JavaScript course and I came across the compound conditional statement and nested conditional statement. Could anyone explain the difference and how it could be used, maybe with some examples?


  • B00B00
    edited June 2016

    Compound statements are statements using two or more logic operations.
    if (condition1 && condition2) { /* stuff */ }

    Nested are just what it says on the tin, they're statement block within statement block.

    if (condition1) {
      if (condition2) {

    Both examples yields the same result here. You'll use both types in more complex scenarios.

  • do && and || have the same meaning in Javascript as Java?

  • Yes. && - and; || - or.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!