This following code is taken from Backbone.js Events#off()
How can I simplify the IF part so it’s easy to understand ?
for (i = list.length - 2; i >= 0; i -= 2) {
if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) {
list.splice(i, 2);
}
}
Some boolean maths:
I think the disjunctive normal form is much easier to understand than the negated conjunctive normal form.
To make the single parts easier to understand, use speaking variable names (I don’t know the scope of this, you may find something better):