Use else if to specify a new condition to test, if the first condition is false. So we have to create our own utility method or use 3rd-party libraries like jQuery or Lodash to check if an object has own properties. JavaScript simply uses different operations in a boolean context versus in a coercion context. Examples of truthy values in JavaScript (which will be coerced to true in boolean contexts, and thus execute the if block): Last modified: Sep 15, 2020, by MDN contributors. If a condition is true, you can perform one action and if the condition is false, you can perform anothe JavaScript Conditional Statements: IF, Else, Else IF (Example) Home But first, let’s see what happens with boolean values. This is because in JavaScript, or actually means and or. Everything else in JavaScript is a truthy value and evaluates to true. First, all objects are truthy, so you can wrap any value in an object and it … !true; // negating true returns false <