|
@jviide | |||||
|
I bet you M. C. Escher would have loved JavaScript. pic.twitter.com/tj3JT9xtx2
|
||||||
|
||||||
|
Cristian Bote ⚛️
@cristianbote_
|
26. stu |
|
Hmm 🤔 now I'm intrigued! What kind of sorcery you've used for the loop? SVGs?
|
||
|
|
||
|
Joachim Viide
@jviide
|
26. stu |
|
A magician never reveals their secrets 😉
(It's text-on-a-path, just conveniently twisted around to meet itself in the middle. Compression artifacts are great for obscuring shoddy seams!)
|
||
|
|
||
|
Mike Barkmin 🐧
@mikebarkmin
|
27. stu |
|
I guess it is a very simple rule. JavaScript uses the type of first term for the comparison. So JavaScript will try to convert the second term to this type. Thus, we compare a < b (String), b < c (Number), c < a (String).
|
||
|
|
||
|
Joachim Viide
@jviide
|
27. stu |
|
IIRC numeric values take precedence over strings here, so in a < b the a is coerced to a number. But yeah, otherwise that's the gist of it 🙂
|
||
|
|
||
|
Marko Laakso
@ikisusi
|
26. stu |
|
I suspect Bach just came up with something based on your tweet, Per Tonos they say.
|
||
|
|
||
|
Joachim Viide
@jviide
|
26. stu |
|
|
||
|
Emmie Päivärinta
@EmmiePaivarinta
|
27. stu |
|
It works because the last one compares strings, while the others cast strings to numbers, right?
|
||
|
|
||
|
Joachim Viide
@jviide
|
27. stu |
|
Yup!
|
||
|
|
||
|
rong-sen
@igarshmyb
|
27. stu |
|
I guess it is a matter of comparing numbers or strings.
|
||
|
|
||
|
Joachim Viide
@jviide
|
27. stu |
|
Indeed: if one operand is a string and the one is a number then they're both compared as numbers.
|
||
|
|
||