-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
Javascript allows to use a clutch of different comparisons with the equal operator, but the focus in this project lies in the following operators:
Nr. | Operator | Description | Example |
---|---|---|---|
1 | "==" | equal to | "1.0e0" == true//is true |
2 | "===" | equal value & type | "1.0e0" === true//is false |
Example 1 is true, because operator 1 converts the string and the boolean type into type number and than compares them.
Just for clarification: 1.0e0 = 1.0 * 100 = 1.0 * 1.0 = 1.0
Even though both values in Example 2 are the same in meaning, they are different in type and that is why the result is false.
Using operator 1 with mixed types should be avoided if possible, because of clearer purpose of the code. If it is still used, an explicit conversion should be initialized.
The user interaction part, after setting some input values, could look like the content as seen below by starting "index.html" in a web browser.
The User given input is compared with operator 1 and 2. The result for operator 2 is always false, because for the User input in "comparing.js" is no conversion done.
To use the project just download the files and execute "index.html". Note that all files should be placed in the same folder so that the functionality of the code is guaranteed.
This knowledge was gained:
-
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman
-
Github markdown, syntax highlight of code blocks in the table cell asked by Ziav and answered by Pokechu22