Closed sleeyax closed 5 years ago
The symlink commit is fine, but the "Allow 0 as truthy value" commit is incorrect.
The problem with JavaScript as compared to other (more serious) programming languages is it's general "fluidity".
For example false == 0
is true
, and '' == 0
is also (unfortunately) true
.
But, false === 0
is false
, and '' === 0
is false
, while 0 === 0
is true
.
Wait, I'm getting confused on what you want to achieve exactly if my commit is considered incorrect. I think it's best you take it over from here.
It's simple, 0
makes sense to be truthy, while ''
and false
should still be falsey.
Your commit adds addonConfig[key] == 0 ||
, which makes false
, ''
and 0
truthy.
While addonConfig[key] === 0 ||
makes only 0
be truthy, while false
and ''
remain falsey. (which I think they should)
So you're basically just missing one =
in your statement, nothing else.
The purpose of open source is for everyone to help one another, u help me with fixing something, I help you with understanding something you might not have understood before.
==
presumes fluidity, which means all falsey == falsey
, so if something == 0
, this also presumes something == false && something == ''
===
presumes an exact match, if something === 0
, this means something !== false && something !== ''
you can try this code in JS:
var zero = 0
if (zero == false && zero == '')
console.log(true)
as opposed to this code in JS:
var zero = 0
if (zero === false && zero === '')
console.log(true)
and you will get different results
Don't worry I know javascript basics lol, it's just easy to overlook a single character.
Thanks for your willingness to help & explain though, I appreciate it
Overlooking (or simply not understanding correctly) and getting a clear explanation can often lead to great things. I sometimes stumble over my own github posts from years ago on some modules where complex things are explained (sometimes even explain myself) and go like "oh.. lol.."
I've learned a lot from github and helping open source projects, human memories can be flawed, but these comments could stay forever.
I like to imagine some poor soul 50-200 years from now hitting these discussions on some random google search and getting small puzzle pieces that help them to reach their objectives. (which might not be that far fetched)
Besides, there are so many videos on youtube about the crazy logic of JS.. it's crazy regardless of knowledge.
Check this: https://charlieharvey.org.uk/page/javascript_the_weird_parts
Here are some example insanity checks:
js> 9999999999999999
10000000000000000
js> 0.1+0.2==0.3
false
js> Math.max()<Math.min()
true
edited previous comment to add some serious insanity examples
Fixes issue #27 & #28