wordle source code mystery


I was looking through the source code for wordle after being inspired by 3blue1brown

While going through and just annotating the code, I noticed a function for determining whether or not a link could be shared. Here's the full function:

function As(e, a, s) {
  try {
    (t = navigator.userAgent || navigator.vendor || window.opera),
      (!/(android|bb\d+|meego).+mobile|manymore|xiino/i.test(t) && !/1207|manymore|zte\-/i.test( t.substr(0, 4))
    )
    || navigator.userAgent.toLowerCase().indexOf("firefox") > -1
    || void 0 === navigator.share
    || !navigator.canShare
    || !navigator.canShare(e)
       ?
       (function (e) {
         throw new Error("writeText() failed");
           // checks for plaintext yadda yadda
       })(e.text).then(a, s)
       :
       navigator.share(e);
  } catch (e) {
    s();
  }
  var t;
}

First it looks through the user agent/vendor string or if it's simply opera (hmm, lol?) and then a variety of other conditions here reduced to a few:

(t = navigator.userAgent || navigator.vendor || window.opera),
  (!/(android|bb\d+|meego).+mobile|manymore|xiino/i.test(t) &&
    !/1207|manymore|zte\-/i.test( t.substr(0, 4)
  )
) ||

I also learned about these navigator propetry share and canShare. Cool. There was also a little easter egg when looking up what ps(x) did:

function ps(e, a) {
  var s,
      t,
      o,
      n,
      r = {

But the next line was something I had never seen in javascript and why I wanted to memorialize it here in a post:

void 0 === navigator.share ||

What does void 0 do? When evaluated it returns undefined.

And that's it. It returns the primitive value of undefined, here used in a comparison. Pretty cool : ).

That's it, that's the post.