19 lines
650 B
Plaintext
19 lines
650 B
Plaintext
When a variable is assigned an ``++undefined++`` or ``++null++`` value, it has no properties. Trying to access properties of such a variable anyway results in a ``++TypeError++``, causing abrupt termination of the script if the error is not caught in a ``++catch++`` block. But instead of ``++catch++``-ing this condition, it is best to avoid it altogether.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
if (x === undefined) {
|
|
console.log(x.length); // Noncompliant; TypeError will be thrown
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::rspecator-view[]
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::rspecator-view[]
|