Monday By Noon

javascript – Can you explain why ++[[]][+[]]+[+[]] = 10

javascript – Can you explain why ++[[]][+[]]+[+[]] = 10 – Stack Overflow.

Not only is the original post itself interesting, but the fact that someone took the time to so delicately (and thoroughly) explain an answer is what really got me. I’m not usually one to put too much emphasis on or value in 100% crowdsourced endeavors, but this is not the first thread like this I’ve seen on StackOverflow, and I can’t tell you how many times Googling has sent me to the site with a very to-the-point answer. For me, StackOverflow breaks the norm in that regard.

If you’re not actively taking advantage and participating in this community, I’d like to strongly encourage you to try and make that a habit. We are saturated with smart people, and this thread goes to show you that sometimes you should just ask.

A lot of pride comes from figuring out something on your own, but with that comes a sheltered experience that likely would be more worthwhile and valuable had you consulted someone else. It’s difficult to strike a balance between self education and flat out asking questions, but I think it’s an important balance to find.

There's a conversation brewing

  1. Let’s make it simple:

    ++[[]][+[]]+[+[]] = 10
    
    var a = [[]][+[]];
    var b = [+[]];
    
    // so a == [] and b == [0]
    
    ++a;
    
    // then a == 1 and b is still that array [0]
    // when you sum the var a and an array, it will sum b as a string just like that:
    
    1 + '0' = 10

By all means, contribute

Leave a comment

Powered by Fusion

This article is so meta

Published December 29th, 2011

Random article

Loading...

My new ebook: Client Oriented WordPress Development is on sale now!