97
GiddyNaya
13d

Javascript why? (-‸ლ)

Comments
  • 8
    That is just wonderful.
  • 5
    Just when I thought I've understood JavaScript😫 .... baNaNa! .... This z just crazy!!!
  • 11
    JS really has the most fucked up coercion rules I've ever seen
  • 32
    ('b' + 'a' + + 'a' + 'a').toLowerCase()

    + 'a' is NaN
    ('b' + 'a' + NaN + 'a').toLowerCase()

    everything gets casted to string and concatenated

    ('baNaNa').toLowerCase()

    banana

    js's type handling is kind of nuts. Try the following

    []+{}*[]+[]+{}*[]+[]+{}*[]+[]+{}*[]+[]+{}*[]+[]+{}*[] + " batman!"
  • 11
    For those who would like explanation, taken from https://freecodecamp.org/news/...

    Unary + operator has higher precedence over binary + operator. So essentially what it does is:

    ('b'+'a'+ (+'a') + 'a').toLowerCase();

    Unary plus triggers numeric conversion for string 'a'. Since the string does not represent a valid number, the result is NaN. On the next step, expression 'ba' + NaN + 'a' is evaluated.
  • 6
    Damn JS, a freaking meme language.
  • 2
    cast + concatenated= castrated
  • 1
    @dozingncoding 10/10 would destroy all software again
  • 1
    hahahahahahahaha
  • 0
    @dozingncoding Nananana batman !
Your Job Suck?
Get a Better Job
Add Comment