Performance of Array.prototype.every(), Array.prototype.some()

I was writing a userscript a couple of weeks ago and had the opportunity to use Array.prototype.every()/some() for the first time. (I only needed one of them — I ended up going with some() for semantics reasons.)

This wasn’t a performance-critical context, but nevertheless I started to wonder if every() would immediately return false as soon as it found an element that didn’t meet the condition, and some() would immediately return true as soon as it found an element that did meet the condition.

MDN states that they do, but I wanted to see some numbers. So I ran a handful of quick n’ dirty tests in the Firefox console to check it out. For the sake of organization, here’s the setup:

function bench(label, test, loops) {
    loops = +loops || 10;
    let t = [];

    for (let i = 0; i < loops; ++i) {
        let tt =;
        t.push( - tt);

    let avg = Math.round(t.reduce((a, b) => a + b) / loops);
    console.log(`${label}: ${avg}ms avg of ${loops}`);

const a = [1, 1, 1, 1, 1, 1, 1, 1], b = [0, 0, 0, 0, 0, 0, 0, 0];
const isEqualToOne = n => n === 1;

Here are the tests:

bench('every() is true', () => {
    for (let i = 0; i < 10_000_000; ++i)

bench('every() is false', () => {
    for (let i = 0; i < 10_000_000; ++i)

bench('some() is true', () => {
    for (let i = 0; i < 10_000_000; ++i)

bench('some() is false', () => {
    for (let i = 0; i < 10_000_000; ++i)

Here are the relevant computer specs:

And here are the results in Firefox 74.0:

every() is true: 1501ms avg of 10
every() is false: 1382ms avg of 10
some() is true: 1339ms avg of 10
some() is false: 1459ms avg of 10

It looks like there is indeed a difference, albeit a small one. Specifically,

I wanted to see how the results compared in other browsers, so I attempted to run these tests in both the new and legacy versions of Microsoft Edge, as well as Chrome. In doing so, I discovered that V8 and Chakra appear to cache function calls after the first couple of iterations, causing subsequent iterations to clock far shorter times and invalidating the output of bench().

Frustratingly, there does not appear to be a way to disable this behavior, so I had to significantly decrease the iteration count using the loops parameter I just happened to have had the foresight to include. I also had to decrease the number of calls to every() and some() in Edge Legacy and increase it in the new Edge and in Chrome to get reasonable times.

Here are the results:

(Yes, I really did have to limit it to just 2 iterations in V8 before it started caching.)

The difference appears significantly larger in Chakra at 22.6%/27.2% faster, and is just ridiculous in V8 at a whopping 67%/64% faster. It’s not immediately clear to me why when I compare the source implementations, so perhaps someone more familiar with the code might be able to shed some light? It doesn’t help that the SpiderMonkey and ChakraCore implementations are literally just JavaScript, so it’s got to be something way under the hood. But here are the links anyway:

All told, since I was just writing a userscript for Firefox, which is my daily driver, for personal use, I’m not too worried. But I did learn a thing or two about Array.prototype.every() and Array.prototype.some(), more than I bargained for, and I thought it might interest other JS performance junkies, which is why I’ve blogged about it. Hope you learned from it, too.

Talk.CSS #46

Well, I haven’t blogged about Talk.CSS since my first two times there. That’s not good. I had a few more but I never got around to them due to chronic illness, executive dysfunction and whatnot. But today, the only thing I’m down with (and have been since Tuesday) is a throat infection that hasn’t gotten worse yet, so I’m making the most of tonight by pushing this one out.

So I went to Talk.CSS today, the first of the year. This time it’s at Microsoft Singapore’s new office at Frasers Tower. It would be my first time there after my last visit to the old office for last year’s Insider Dev Tour, so I was pumped.

But this being a new environment, I had to take precautions to ensure things went as smoothly as possible. To that end I pinged Hui Jing and Wei Gao on Twitter:

And then I had the brilliant idea of going through Sarah, my Microsoft MVP contact from Microsoft Singapore, as well. It would be my first time meeting her in person. She said she’d pick me up after finishing her meeting; I couldn’t go inside so I waited at the lobby for her.

Turns out, when I first got to the lobby, I was so calm that I could confidently decide to tweet this to the former two:

That’s right: even before I’d set foot in the new office, my selective mutism was already a no-show. This could have partly been because I made it a point to be early so I had time to collect myself, but I’m serious, it’s all Microsoft. My 11 years of guaranteed speech at the old office appear to have carried over seamlessly.

Anyway, Sarah came to pick me up first; it would be another 10 minutes before Hui Jing got there. Naturally, she was the first person I spoke to.

And here I was, at Microsoft Singapore’s new office at Frasers Tower:

The Microsoft logo at the new Singapore office.
The Microsoft logo at the new Singapore office.

Read on for Hui Jing’s reaction to hearing my voice for the first time and, of course, the talks themselves! I know the talks are probably what you came here for but this experience was particularly important to me so I just had to share. Let a disabled person have their limelight, won’t you?

It’s my 28th birthday!

Happy birthday to me, I’m officially 28! This afternoon I got to see Spies in Disguise with some folks from church I’m comfortable with, breaking a 16-year curse of never having a proper even-numbered birthday celebration with anyone. And while I was really scared sitting in the pitch-black cinema for several minutes, when the screen finally came on it did so with no sudden sound effects and I was never startled. I’m pretty glad.

Spies in Disguise poster.
Spies in Disguise poster.

Anyway, elephant in the room — I never got around to making my announcement regarding Stack Overflow, and I’m still not ready to say a word about my life situation in general. I will say that my current break from the site

  1. is intermittent,
  2. is unplanned, and
  3. has very little to do with anything on part of Stack management.

Oh and I still have no plans to step down as moderator, so don’t worry. Things aren’t terrible on my end. In the short term (i.e. sometime this month) I plan to update my battlestation with my biggest incremental update to Radiance yet. Beyond that I will continue to work on the updates to the LEGO Room that I mentioned last year, as well as miscellaneous housekeeping elsewhere on my site.

But in general, I will be taking things slow. I wish I didn’t have to, but right now I have to if I want to keep it together for a little longer, and to be clear it’s still a nice thing to be able to do, not something I’m reluctantly settling for. Talk to you later.

Protected: Mozilla Developer Roadshow 2019: a postmortem

This post is password-protected. If you have the password, please enter it below:

My pronouns are they/them and he/him

Comments closed

Yesterday was International Pronouns Day. This post is intended to be a precursor to a longer and much more serious post about where I am in a few specific aspects of life and what my plans are moving forward. Not that this post isn’t serious — it very much is — just that one will be even more so. And the reason this post is serving as a precursor is because the topic of third-person pronouns will be of extreme relevance to that one.

Anyway, I’ll begin this by reiterating the headline: My pronouns are they/them and he/him. To expand:

  1. They/them is very much preferred, especially online, where my gender identity is almost entirely irrelevant to what I say and do, except in situations where gender biases actually matter (which is outside the scope of this post as those are too complicated and convoluted).

  2. However, I consider he/him acceptable and do not consider it to be misgendering me because I have always lived as, and continue to identify as, a cisgender boy — just one who was fortunate enough to have been immune to most forms of gender binning growing up.

Although I consider myself cis, I have very strong solidarity with the transgender and especially the non-binary communities, admittedly in part because I share a lot of the contentions trans and non-binary people have about various gender issues, such as gender roles and stereotypes, and conformity thereto. I’ve been told that this is usually a good sign that I’m non-binary myself, but this is not a coming-out post. I do not claim to fully understand trans or non-binary issues, and cisgender privilege and biases are a very real aspect of who I am today, which is why I continue to identify as cis.

But I will say that I consider the singular they/them pronoun very validating and it would delight me if you were to use it to refer to me, even if you know that I’m a guy. This serves a dual purpose:

  1. Gender neutrality, as mentioned above. Beyond a name my parents and God gave me that I love very much and simply happens to be masculine, I don’t go out of my way to present as male online, so except in gender-sensitive matters, my gender should otherwise be irrelevant to what I say and do.

  2. The other big reason is that I’ve had a decade-long history of being bullied exclusively by other boys, and protected by girls and a small handful of the better boys, so this is also kind of my way of distancing myself from my gender group. I don’t want anyone to focus so much on my gender that they start associating me with the very same ilk who have threatened and harmed me growing up. That’s the most offensive thing you could do to me in this context because it minimizes the harm I also experienced. I have a relevant Twitter thread that goes into more detail on this.

All told, if you call me he/him, either because you’re used to it or for other reasons, don’t worry about it. I’m a guy and I own it.

In fact, I may be one of the few people for whom the phrase “preferred pronoun” actually applies. I prefer they/them, but don’t object to he/him. However, pronouns are not merely “preferred” for the vast majority of trans and non-binary people. If someone tells you their pronoun is so-and-so, that’s it. In much the same way calling anyone by the wrong name is misnaming them, or calling a trans person by a name they no longer use (or anyone with a new name really) is deadnaming them, referring to someone by an incorrect or obsolete pronoun is misgendering. To that end I’ve found “preferred pronoun” to be quite the misnomer, and I’m honestly not sure how it came to be.

Calling me she/her on the other hand is considered misgendering, but not only does it not make me uncomfortable (so, again, don’t worry!), but, hilariously, the only people who have called me she/her over the years have been cis women and girls in person because I’ve always hung out with them a lot. Heck, it happened again just last Sunday, and we all laughed about it. Meanwhile I only remember one less recent instance of a stranger doing that online, and even then I shrugged it off very easily. I think that counts as a cis male privilege — I assure you, misgendering anyone else, including cis women and girls, hurts them far more than it hurts cis men and boys. You gotta be careful and respectful no matter what.

Anyway, I will go into more depth on some of the aforementioned gender issues… when my follow-up post is ready. It may be a while, though. I’ve been through a lot lately. You can tell because I haven’t caught up on Inktober for almost 2 weeks now, never mind the LEGO Room.