You are viewing a single thread.
View all comments View context
21 points

So there’s yet another level of quirkery to this bullshit then, it seems. 😆 Nice digging! 🤝

I also noticed that if you surround the curlies with parentheses, you get the same again:

> eval('{} + []')
0
> eval('({}) + []')
'[object Object]'
permalink
report
parent
reply
10 points

Yep, parentheses force {} to be interpreted as an expression rather than a block — same reason why IIFEs have !function instead of just function.

permalink
report
parent
reply
1 point
*

I thought IIFE’s usually looked like (function (...params) {})(...args). That’s not the latest way? To be honest I never used them much, at least not after arrow functions arrived.

permalink
report
parent
reply
3 points

/me goes back to get second folding chair.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 2K

    Monthly active users

  • 861

    Posts

  • 14K

    Comments