Proposal - `for .. else ...` (also `while ... else ...`) statement

A tool that is dangerous 99% of the time, is dangerous :-)

What is that link? It doesn't have an href.

Indeed, I can found this in jquery-3.7.1.min.js:

show/hide code
map:function(e,t,n){var r,i,o=0,a=[];if(c(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)}

prettified:

map: function (e, t, n) {
  var r,
    i,
    o = 0,
    a = [];
  if (c(e))
    for (r = e.length; o < r; o++)
      null != (i = t(e[o], o, n)) && a.push(i);
  else for (o in e) null != (i = t(e[o], o, n)) && a.push(i);
  return g(a);
},

If this script stops working, a large number of sites are likely to be affected.

react-dom.production.min.js is also affected:

if(a.alternate)for(;b.return;)b=b.return;else{
1 Like

It’ll never stop being valid, but that doesn’t mean it’s safe for a human to write that code.