== Why is this an issue? When either the equality operator in a test for ``++null++`` or ``++undefined++``, or the logical operator that follows it is reversed, the code has the appearance of safely null-testing the object before dereferencing it. Unfortunately the effect is just the opposite - the object is null-tested and then dereferenced only if it is ``++null++``/``++undefined++``, leading to a guaranteed ``++TypeError++``. === Noncompliant code example [source,javascript] ---- if (str == null && str.length == 0) { console.log("String is empty"); } if (str == undefined && str.length == 0) { console.log("String is empty"); } if (str != null || str.length > 0) { console.log("String is not empty"); } if (str != undefined || str.length > 0) { console.log("String is not empty"); } ---- === Compliant solution [source,javascript] ---- if (str != null && str.length == 0) { console.log("String is empty"); } if (str != undefined && str.length == 0) { console.log("String is empty"); } if (str == null || str.length > 0) { console.log("String is not empty"); } if (str == undefined || str.length > 0) { console.log("String is not empty"); } ---- ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] ''' == Comments And Links (visible only on this page) === on 10 Mar 2015, 14:56:30 Ann Campbell wrote: submitted for your approval [~linda.martin] === on 10 Mar 2015, 15:14:19 Linda Martin wrote: Perfect ! include::../comments-and-links.adoc[] endif::env-github,rspecator-view[]