why does wick use === for if statements and whats the difference from doing ==?
tbh, I never paid much attention to the difference between the two, I always prefer using “===
” because it’s easier for me to remember to have 3 equal signs rather than 2
Therefore, my info is more likely incorrect
“==
” only checks if two things are equal.
“===
” checks the type of things and how they are equal.
For example, if you wanted to see if something is equal to “null
” or “undefined
,” or want to see if it’s equal to “true
” or “false
,” you would have to use “===
”
If you wanted to compare something to a variable, text in quotes, number, etc., you can use “==
” or “===
”
If you compare something to “true
” using “==
,” it’ll check to see if that thing is literally equal to “true
,” but if you use “===
,” it will look deeper into what “true
” is before stating if the if
statement is false.
(I made some edits. Before the edit, I had the info hidden as an html comment using “<!-- -->
”)
Ahhh thanks!
wick is programmed in javascript, and you also program wick games in javascript too because making a javascript interpreter in javascript is far more easier than any other programming languages, since javascript has the native ability to run javascript.
the difference between === and == is that when you compare using “===”, there are no type conversions but if you compare using “==” there are. so if you have 5 == "5"
they return true but if you have 5 === "5"
, since they are not the same type (number vs. string) they will return false. If you have something like " \t\r\n" == 0
it will also return true for some reason. And so will [] == 0
. === exists so you can be more strict and using it will decrease the chance of errors.
thanks that cleared it up for me!
example:
if (key === “up”)