Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It’s the answer to the question: “If I sit down in front of a blank HTML page, and want to start being productive immediately, what do I need?” … and the tie to go along with jQuery‘s tux and Backbone‘s suspenders.

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

javascript – Can (a== 1 && a ==2 && a==3) ever evaluate to true? – Stack Overflow

javascript – Can (a== 1 && a ==2 && a==3) ever evaluate to true? – Stack Overflow

Yes, it can. IMHO it is one of the several undesirable consequences of loosely typed languages. In fact, according to an almost anonymous user:

If you take advantage of how == works, you could simply create an object with a custom toString (or valueOf) function that changes what it returns each time it is used such that it satisfies all three conditions.

const a = {
  i: 1,
  toString: function () {
    return a.i++;
  }
}

if(a == 1 && a == 2 && a == 3) {
  console.log('Hello World!');
}

The reason this works is due to the use of the loose equality operator. When using loose equality, if one of the operands is of a different type than the other, the engine will attempt to convert one to the other. In the case of an object on the left and a number on the right, it will attempt to convert the object to a number by first calling valueOf if it is callable, and failing that, it will call toString. I used toString in this case simply because it’s what came to mind, valueOf would make more sense. If I instead returned a string from toString, the engine would have then attempted to convert the string to a number giving us the same end result, though with a slightly longer path.

Worst, it is also possible using the === operator!

var i = 0;

with({
  get a() {
    return ++i;
  }
}) {
  if (a == 1 && a == 2 && a == 3)
    console.log("wohoo");
}

This uses a getter inside of a with statement to let a evaluate to three different values.

… this still does not mean this should be used in real code…

Even worse, this trick will also work with the use of ===.

  var i = 0;

  with({
    get a() {
      return ++i;
    }
  }) {
    if (a !== a)
      console.log("yep, this is printed.");
  }

Javascript insanity?

On Facebook they write

I enjoy JavaScript but this is insanity

Welcome to a language that has approximate math as the only math you can use.

In fact 7110 / 100 * 100 is 7109.99999999 because the first division cannot be exactly represented with with a floating point representation.

Sites like https://baseconvert.com/ieee-754-floating-point come handy…

Those are the moments when I rejoice for choosing Eiffel as my favourite language