DEV Community

acuevasd
acuevasd

Posted on

Scrimba's JavaScript Deep Dive - Part II

Types & Conditionals:

  • If, else if or else -> as usual
  • Switch (something) {case break and default}: can be more useful
  • Primitive types (string, number, boolean, undefined, null & symbol) or Object (everything else). We can look for type with typeof
  • explicit type conversion (with functions) or implicit (automatic // coercion)
  • In conditionality, java script will convert to boolean. All value will be "truthy" (coercion to true) and "falsy" (coercion to false). Remember that: "false", "0", " '' " (empty), "null", "undefined" and "NaN" are the falsy values.
  • For direct comparison, we need to use === as other equals change types. And avoid direct comparison (=)
  • Ternaries do not allow actions. They are nice with value assignment with conditionals
  • && has higher precedent than ||, unless we are using ()

Top comments (0)