Logo
Whitespace: Programming with just spaces and tabs.
  • Home
  • Hot
  • Random
  • Search

Browse

  • AI AI
  • AWS AWS
  • Agile Agile
  • Algorithms Algorithms
  • Android Android
  • Apple Apple
  • Azure Azure
  • Backend Backend
  • Bash Bash
  • C++ C++
  • Cloud Cloud
  • All Categories
As an Amazon Associate ProgrammerHumor.io earns from qualifying purchases.

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

Weird-javascript Memes

Posts tagged with Weird-javascript

JavaScript Is Weird

Javascript Programming Frontend Webdev
9 months ago 504.6K views 1 shares
JavaScript Is Weird
So you're telling me that adding the string 'b' to 'a' twice, then adding 'a' twice more, and calling toLowerCase() somehow produces "banana"? Yeah, that tracks. JavaScript's type coercion is basically that friend who always "helps" by making things infinitely more confusing. Here's what's happening: 'b' + 'a' gives you "ba". Then + + converts the next 'a' to NaN (because unary plus on a string that's not a number = NaN). "ba" + NaN = "baNaN". Add another 'a' and you get "baNaNa". Call toLowerCase() and boom—"banana". It's like JavaScript is gaslighting you into thinking this makes sense. The real question is: who discovered this, and what were they doing at 3 AM to stumble upon it?

Today's picks

Logitech G213 Prodigy Gaming Keyboard, Wired Keyboard – Black | Mech-Dome Keys, Palm Rest, Adjustable Feet, Media Controls, LIGHTSYNC RGB, USB, Compatible with Windows

Logitech G213 Prodigy Gaming Keyboard, Wired Keyboard – Black | Mech-Dome Keys, Palm Rest, Adjustable Feet, Media Controls, LIGHTSYNC RGB, USB, Compatible with Windows

Affiliate
$39.99
Damn fuckers hiding in places I didn't even know existed!!

Damn fuckers hiding in places I didn't even know existed!!

Programming
144.6K views 5 years ago
Self Taught Programmers

Self Taught Programmers

Programming
117.4K views 5 years ago