Is JavaScript Racist?
While I was scrolling on social media, I encountered an interesting post. The post posited an interesting question. Is JavaScript racist? However, as curious as this question may be, I found the methodology employed to tackle it troubling. So today, I'd like to attempt reconsidering the post's conclusion.
After meticulously researching the origin of the Instagram reel I watched1 for a few minutes, I deduced that the idea behind this post first appeared on Reddit a few months ago2 and is a simple visual given in Figure 1.
I used my favourite JavaScript editor (Firefox console) to replicate this study in Figure 2 and found that JavaScript indeed produces such results with skin colour variations of emojis.
For non-coding people out there, let me briefly explain what happened here. When something is between "" in a code, it usually means that is a string. A string is a set of characters. In a JavaScript code, if you want to write your favourite Eurovision 2023 entry, you write "Cha Cha Cha". So JavaScript understands that you mean the text.
But what if your favourite song is Mama ŠČ! from Croatia. Back in the day, all text on the internet was written by USA scientists, and therefore English alphabet was sufficient. However, as the use case widened from several cool universities to the whole word, strings needed to include other characters. The standard currently used on the internet is called UTF-8 (Unicode Transformation Format – 8) and since JavaScript is primarily used for internet purposes, it too uses utf-8 as a default. Therefore, "Mama ŠČ!" is also an acceptable script in JavaScript without any fuss. Similarly, what I wrote in Figure 2 tells JavaScript that I five pieces of texts that happen to be thumbs up emojis.
I put my five pieces of text into an array, which is a storage for multiple strings. And then I sorted this list. The word sort is fairly straightforward, but to explain sorting with JavaScript, lets consider another song "soarele și luna" from Moldova. Lets look at Figure 3.
Fortunately, JavaScript is not also spacist since it sorted the moon (luna) before the sun (soarele). Jokes aside, when strings are sorted JavaScript uses lexicographical order, or the order from the dictionaries. Letter "l" comes before the letter "s", therefore this order. However, what about "ș". This is a letter not used in English. Yet, as it is a letter, it can be expressed in utf-8, and therefore JavaScript can sort it.
Similarly, when we sort the emojis, the only thing JavaScript considers while sorting is their utf-8 codes. To better illustrate this, let's mix things up with Figure 4. Here, it is clear that poor JavaScript only does what utf-8 people tell it and has no personal bias while sorting emoji colour.
Then, we ask the second question, is utf-8 people racist? The way to do emojis with different skin tones is computationally very interesting. Unlike a true emoji, like say "🗾" an emoji with skin tone is actually a combination of two Unicode characters. First the original emoji (👍) and the second is skin tone. When I browsed the skin tone expressions, I saw that they are called "EMOJI MODIFIER FITZPATRICK TYPE-#" where # is a number3. So who is this Fitzpatrick and why is his scale say 1 for light and 6 for dark skin?
Again, I did a brief browsing and found that Fitzpatrick Scale is a numerical classification of skin tones based on their sensitivity to ultraviolet light. Unicode people claim that they elected to use this scale as a basis for skin tone because it is a scientific and neutral way to order skin tones. So, they too acknowledged that when skin tones are incorporated, they will need to be incorporated in an order (since they need to have different tags) which may cause problems. Indeed, weather this scale itself is Eurocentric and or Racist is an ongoing debate. I personally believe, android solved this problem to way too well to exist in the modern world by using green aliens instead of human emojis.
Thus we found that skin tones emojis are actually Unicode character pairs where skin tone is found using Fitzpatrick Scale and that order is used when sorting. However, there is one last question to ask. How do non-alphabetic characters get sorted alphabetically? Simply, alphabetic characters are not alphabetic sorted either. All the Unicode characters are sorted using their numerical value. The actual actual sorting done is sorting numbers. Why is that relevant? Because what if my favourite thing about Eurovision 2023 was the countdown?
In Figure 5 we see a different aspect of emoji sorting racism4. The regular sorting function in JavaScript sorts values in ascending order. Therefore, the most valuable would be the last value.
I am not saying that deciding if a software language is racist based on a particular function and emoji codes is not silly. It definitely is. But even then, the evidence is presented with the wrong implications. The way a computer code sorts utf-8 characters is a poor method of determining racism. And it's unnecessarily complex too. To finish this, let's consider Figure 6: a much simpler computer program to determine if JavaScript is racist.
Which was similar to this video I found on Youtube:
Link to the post https://www.reddit.com/r/programmingmemes/comments/1gmbttv/js_is_racist/ .
https://www.utf8-chartable.de/unicode-utf8-table.pl?start=127808&unicodeinhtml=dec
Yes, I know that Javascript treats numbers as strings too and would think 1500 is smaller than 2 when asked, but how it compares those string characters is based on the numerical value of those characters.









