GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — javascript/conditional/comparators.md at master · octatone/javascript

Expand file tree

/

comparators.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
46 lines (31 loc) · 1.11 KB
/

comparators.md

Copy path

File metadata and controls

46 lines (31 loc) · 1.11 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

Comparators

Lets now focus on the conditional part:

if (country === "France") {
    ...
}

The conditional part is the variable country followed by the three equal signs (===). Three equal signs tests if the variable country has both the correct value (France) and also the correct type (String). You can test conditions with double equal signs, too, however a conditional such as if (x == 5) would then return true for both var x = 5; and var x = "5";. Depending on what your program is doing, this could make quite a difference. It is highly recommended as a best practice that you always compare equality with three equal signs (=== and !==) instead of two (== and !=).

Other conditional test:

  • x > a: is x bigger than a?
  • x < a: is x less than a?
  • x <= a: is x less than or equal to a?
  • x != a: is x not a?
  • x: does x exist?

Add a condition to change the value of a to the number 10 if x is bigger than 5.

var x = 6;
var a = 0;
var x = 6;
var a = 0;

if (x > 5) {
    a = 10;
}
assert(a === 10);

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.