reading-notes

Tif Taylor | Code Fellows

View project on GitHub

Read:08 | Operators & Loops in JS

Textbook: Jon Duckett: HTML & CSS

Comparison & Logical Operators

  • Comparison operator == and === differ only in that === won’t auto-convert the data type and is therefore the more secure one to use
  • With the Comparison not equal to something, it’s better to use !== to preserve the data type
  • Logical operators allow you to compare more than one Comparison operator
  • Logical examples are: && (and), II (or), ! (not)
  • You can google logic operator tables for the truth/false equations of expected results Here’s an example article

For Loop & While Loop

  • Loops check a condition x number of times (if while then it loops until it’s true, if for then checks the number of times you’ve set in the condition)
  • Special case: do…while loop will run at least once even if false
  • In for loops initialize (var i = 0;), set the condition (i < 10;) and update on next iteration (i++)

Back to Home