More awful JS fun facts

array comparison

You can’t check array value equality in JS using either the === (strict equality) operator or the == (loose equality) operator. This would be all fine and good in a typed language where it’s very normal to use strict mem references and there would doubtless be a built-in comparator function.

In JS, one of the accepted solutions is to serialize the arrays and compare their string values.

(JSON.stringify(request.data.words) != JSON.stringify(highlightWords[request.data.wordType])

This will work fine with primitives, but tread with caution if comparing arrays of objects, because then you will need to make sure their serializations accurately represent all the data you care about comparing. Of course, if they contain a lot more data than necessary for your comparator, then this is a slow approach and you’re better off writing your own comparator lambda and running it over all values.

destructuring assignment

The destructuring assignment is the JS equivalent of Python’s dict.update().

var options = {'a': 1, 'b': true};
// ...
var newOptions = {'a': 2};
options = {...options, ...newOptions}; // {'a': 2, 'b': true}