420chan now has a web-based IRC client available, right here
Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the float Name#Password
Comment
[*]Italic Text[/*]
[**]Bold Text[/**]
[~]Taimapedia Article[/~]
[%]Spoiler Text[/%]
>Highlight/Quote Text
[pre]Preformatted & Monospace text[/pre]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


Community Updates

420chan now supports HTTPS! If you find any issues, you may report them in this thread
javascript by Lydia Gudgedale - Sat, 12 May 2018 20:10:25 EST ID:r5si74OP No.37533 Ignore Report Quick Reply
File: 1526170225292.png -(863168B / 842.94KB, 1452x2208) Thumbnail displayed, click image for full size. 863168
just sharing this enjoyable picture image with a text post
>>
Rebecca Blebblelock - Sat, 12 May 2018 23:20:04 EST ID:lP7MCiRB No.37536 Ignore Report Quick Reply
1526181604017.gif -(34345B / 33.54KB, 600x450) Thumbnail displayed, click image for full size.
>>37533
Yes
>>
Isabella Gimmerhall - Sun, 13 May 2018 06:14:36 EST ID:Xm/W+3lL No.37537 Ignore Report Quick Reply
I liked that. Thanks for sharing, OP.
>>
Doris Cradgelot - Fri, 18 May 2018 03:26:20 EST ID:+joVuqaF No.37543 Ignore Report Quick Reply
1526628380219.jpg -(46819B / 45.72KB, 330x512) Thumbnail displayed, click image for full size.
That behavior's not actually a bug. Loose equals (`==`) just means that type coercion is allowed. Section 11.9.3 of the ES5 specification says if both things being compared have the same type, they're compared via identity; if they have different types, perform the following steps are until both things have the same type (then they're compared via identity).

for x == y:

2) If x is null and y is undefined, return true.

3) If x is undefined and y is null, return true.

4) If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).

5) If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.

6) If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.

7) If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).

8) If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y).

9) If Type(x) is Object and Type(y) is either String or Number, return the result of the comparison ToPrimitive(x) == y.

So according to rule 4: 0 == "0" reduces to 0 == Number("0") which reduces to 0 == 0 which is true.

And according to rule 8: 0 == [] becomes 0 == [].valueOf(). Since [].valueOf() doesn't return a primitive (it returns an array, which is an object), the expression becomes 0 == [].toString() or 0 == "". Rule 4 is invoked: 0 == Number("") resolves to 0 == 0, which is true.

"0" == [] does not work because the rules for loose equals coerce it into "0" == "" which is unquestionably false.

If you don't like type coercion, stop comparing things of different types, or use strict equals, which does not coerce types at all.


Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.