Javascript is the most popular scripting language in use today

Explanation: it’s mostly due to how js does type conversion. for the Ls, it’s

[] is an empty array ![] is treated as false combining a boolean with the empty array returns “false” as a string (so true + [] = “true”, false + [] = “false”) ! + [] is treated as true ! + [] + ! + [] is treated as 2 since true + true = 1 + 1 = 2 so you have “false”[2], which is l for the o it’s [] is an empty array [] + {} returns “[object Object]” as a string ({} + [] returns 0) ![] is false !![] is true +!![] casts it to an integer so that part is “[object Object]”[1], which returns “o”

addie,
@addie@feddit.uk avatar

Javascript might be the most widely-used scripting language in use today, due to its browser dominance. Most popular would imply that it’s not completely despised by everyone that has to use it, which is misleading. Even TypeScript tutorials are about 50% ‘you have to understand what Javascript does wrong here’.

nulldev,

The explanation is about as understandable as the JS code, however thanks OP, TIL

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines