User "Krinkle" posted a comment on MediaWiki.r80572.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80572#c16689
Commit summary:

Fix bug in mw.Map + fix bug 26801 + wrapper mediawiki.special.upload.js
* Map.prototype.exists was checking the type of the wrong variable. Fixed now, 
checking multiple at once is now possible (as documented)
* bug 26801: No references to legacy globals, use mw.config everywhere in core 
(grep search for 'wg' in /resources returned only 
* Addressed some JS Lint warnings (combining var statements, faster and less 
code);
* Removed trailing tabs and spaces

Comment:

A non-strict comparison only compares the values unrelated to their types.

A strict comparison only returns true if both the value and the type are the 
same.

There's only 1 kind of variable that can be equal to a non-empty string (ie. 
"Blankpage"), so there's no need to check the type.

However comparing things like numbers, boolean or empty values need strict 
comparison (but only if you need them to be).
For example:

* If one needs a variable to be 1 (either as a number or as a string "1"). 
non-strict comparison to == 1 is perfect imho
* If one needs someting to be 0 (as a number, not a string or boolean false), 
then a strict comparison to === 0 is needed. Because '0' (string) has the same 
value, but a different type.
* If one needs a variable to be equal to a certain word, then a non-strict 
comparison to == 'my word' is suffecient and can't fail as there are no 
non-strings that can have the same value.
* etc.

Hope that made sense :)

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to